7. SharePoint Solutions (Classic Solution)
SharePoint Solutions, which are now
referred to as Classic Solutions, are recommended only for
administration automation and tasks. To create these solutions you must
install SharePoint on a Windows Server machine and develop locally with
Visual Studio.
Feature Designer
Building SharePoint Solutions as
Classic Solutions will still require using the Feature Designer to
manage your solutions features and package. A feature can have multiple
items in it, such as a Delegate Control or Event Receiver. In addition,
features can be dependent on the activation of other features. For
example, Feature A may require that Feature B be activated. Features
are also scoped to different levels in SharePoint at the Farm, Site,
Web, and Web Application level. The Feature Designer enables you to
configure your features with all this functionality. Figure 5 shows the Feature Designer.
In addition to working with the graphical
designer, you can also work with the XML that Visual Studio creates for
your feature. You have two choices in working with the XML. First, you
can add custom XML to the auto-generated XML that Visual Studio
creates. Second, you can edit all the XML, even the auto-generated
parts. If you get your edits wrong, it could stop you from working with
your feature in Visual Studio. Editing all the XML is recommended only
for advanced users who cannot meet their needs by inserting new XML
into the Visual Studio auto-generated XML.
SharePoint Solutions Project and Item Type Templates
The project types for Visual Studio
2012 are based on a combination of SharePoint 2010 and SharePoint 2013
project templates. There are some overlapping items for each version,
but all project templates are listed together under the
Office/SharePoint ⇒ SharePoint Solutions category. Table 3 lists the different project type templates, and Table 4
lists the item type templates that you can use. Many of the project
types have been moved to item types to make it easier to find what type
you are looking for.
TABLE 3: SharePoint Solutions Project Type Templates
NAME |
DESCRIPTION |
SharePoint 2013 Project |
This templates enables you to start with
an empty project that has all the necessary elements for you to get
started, such as folders for references, features, and solutions, and a
key to strong-name your assembly. |
SharePoint 2013 Silverlight Web Part |
This template provides the files need to
create a SharePoint 2013 package that hosts a Silverlight application
and also provides the web part project with which to associate the
Silverlight application. |
SharePoint 2013 Visual Web Part |
This template creates a new SharePoint
2013 Visual web part, which enables you to drag and drop controls onto
your web part for your user interface rather than writing the user
interface in code. It contains a Web Part and a User Control item. |
Import SharePoint 2013 Solution Package |
This template enables you to import an existing WSP package for SharePoint 2013. |
Import Reusable SharePoint 2013 Workflow |
This template enables you to import an
existing reusable SharePoint 2013 Workflow that you create in
SharePoint Designer 2013, which you can then customize and deploy from
Visual Studio. The import is one way, and after it is modified in
Visual Studio, you cannot go back to SharePoint Designer. |
SharePoint 2010 Project |
This templates enables you to start with
an empty project that has all the necessary elements for you to get
started, such as folders for references, features, and solutions, and a
key to strong-name your assembly. |
SharePoint 2010 Silverlight Web Part |
This template provides the files needed
to create a SharePoint 2010 package that hosts a Silverlight
application and also provides the Web Part project with which to
associate the Silverlight application. |
SharePoint 2010 Visual Web Part |
This template creates a new SharePoint
2010 Visual web part, which enables you to drag and drop controls onto
your web part for your user interface rather than writing the user
interface in code. It contains a Web Part and a User Control item. |
Import SharePoint 2010 Solution Package |
This template enables you to import an existing WSP package for SharePoint 2010. |
Import Reusable SharePoint 2010 Workflow |
This template enables you to import an
existing reusable SharePoint 2010 Workflow that you create in
SharePoint Designer 2010, which you can then customize and deploy from
Visual Studio. The import is one way, and after it is modified in
Visual Studio, you cannot go back to SharePoint Designer. |
TABLE 4: SharePoint Solutions Item Type Templates
NAME |
DESCRIPTION |
Silverlight Web Part |
This template adds the required
Silverlight project and asks how you would like to associate the web
part in the project by either creating a new Silverlight Web Part or
associating it later. |
Visual Web Part |
This template adds a new Visual Web Part to the current solution. |
Web Part |
This template enables you to create a web part for your SharePoint environment. |
List |
This template now provides the ability to create a list with a custom set of fields or create a new list from an existing list. |
Event Receiver |
This template provides a wizard that
enables you to select the type of event receiver to create, the event
source it is created with, and the events you would like to implement. |
Content Type |
This template provides a wizard to create a content type item with a reusable collection of fields. |
Workflow |
This template provides a wizard that
enables you to create SharePoint 2013 workflows that can be based on a
list or site in Visual Studio. |
Workflow Custom Activity |
This template creates a custom activity that can be reused in Visual Studio or in SharePoint Designer. |
Sequential Workflow (Farm Solution Only) |
This template provides the ability to create the SharePoint 2010 sequential workflows. |
State Machine Workflow (Farm Solution Only) |
This template provides the ability to create the SharePoint 2010 state machine workflows. |
Business Data Connectivity Model |
Use this template to create a resource
file for your BCS model. A resource file enables you to localize the
names in your model and apply permissions to objects. |
Empty Element |
This template creates an elements.xml
file that enables you to define SharePoint artifacts using XML. The
most common usage would be defining a field in your SharePoint project. |
Application Page (Farm Solution Only) |
Use this template to create an application page, which is just an ASP.NET page hosted in SharePoint. |
Site Column |
This template creates the elements.xml
file and default field attributes for the custom site columns that can
be used in the fields or content types. |
Module |
This template creates a simple module file with a sample text file showing how to deploy files. |
Site Definition (Farm Solution Only) |
This template enables you to create the SharePoint 2010 site definition files that can be deployed at a farm level. |
User Control (Farm Solution Only) |
You can create a user control that you
can use in an application page or web part with this template. You can
design the control using the graphical designers in Visual Studio by
dragging and dropping your controls onto the design surface. |
Importing Packages
The concept of importing and exporting
SharePoint packages has been around in the user interface since
SharePoint 2007. Since then the product team has improved the
capabilities and standardized on the packages that are created. The
capabilities are now found in SharePoint, Visio, SharePoint Designer,
and Visual Studio. This means that the combination of those tools
enables you to develop your solutions quickly and use the tool that is
right for the step in development. Visual Studio provides the largest
set of capabilities for completing the packages and fine-tuning
changes. To import SharePoint packages known as Web Solution Packages
(WSP) there are two options: either a generic WSP package or a Reusable
workflow. Both of the packages have a Visual Studio Project template
with wizards to help guide you through importing the packages. If you
are unfamiliar with WSPs, you should learn more about the internals of
how they work because they provide valuable features that enable you to
install and ship your SharePoint Solutions to multiple environments.
Importing WSPs
When doing SharePoint development, you
must perform your work inside of the user interface or SharePoint
Designer. After you complete designing your solution, you must export
items or even the entire sites to move the information around and
modify it. With Visual Studio you can import the WSP solution, which
contains the exported site or items that you have exported to move into
your Visual Studio solution. Visual Studio imports your lists, fields,
content types, and other artifacts, so you can start working on them
quickly in Visual Studio. WSPs are still the recommended packaging
format for all SharePoint Solutions that are not apps.
Reusable Workflows
Similar to the project template for
importing a generic site WSP, you can also import a reusable workflow
that you created using SharePoint Designer. The reusable workflows
created in SharePoint are declarative workflows that consist of XML
statements to define the workflow instead of code. The reusable
workflow template enables you to create your workflow in SharePoint
Designer and then import it into Visual Studio to convert it to a code
workflow that can be reused on your SharePoint sites.
Package Designer and Explorer
After you create your features, you
need to package them together and deploy them to your server. This is
where the Package Designer and the Explorer come into play. If you have
used SharePoint previously, you know that SharePoint supports a format
called a Web Solution Package (WSP), which is just a CAB file that
contains your solution files and a manifest or XML file that tells
SharePoint what to do with your solution when deployed. You could write
all the XML yourself and compile your CAB file, but Visual Studio makes
this much easier. Figure 6 shows the Package Designer.
The Package Designer gives you the ability to do the following:
- Add multiple items to the solution using a graphical interface
- Control whether the web server resets
- Add assemblies to your package
- Write package rules that enable you to validate your package programmatically before deploying it to the server