Share via


Building Block: Solutions

Applies to: SharePoint Foundation 2010

The Microsoft SharePoint Foundation solution framework provides a way to bundle extensions to SharePoint Foundation in a solution package (.wsp file). A solution package is stored in a CAB file with the .wsp extension. It can contain Features, site definitions, Web Parts, and assemblies. The solution framework provides a unified infrastructure for deploying solutions. The solution framework, when used with Features, provides functionality can be enabled or disabled at a specified scope. The framework also provides a mechanism that can be used to deploy and upgrade existing solutions to different servers in the server farm. Solutions can also be localized to support a greater range of users.

There are two types of solutions: sandboxed solutions and farm solutions.

  • A sandboxed solution can be deployed by a site collection administrator to a site collection’s solution gallery. These types of solutions have access to a subset of the server object model and execute in a security restricted context that provides isolation and monitoring of the solution’s code. A sandboxed solution can be validated by using a solution validator. The farm administrator can enable or disable sandboxed solutions and set usage limits to protect servers in the farm from malicious code.

    Note

    The term user is sometimes used in place of sandboxed, especially in the object model for the sandboxed solutions system. For example, the namespace with the primary APIs for the system is Microsoft.SharePoint.UserCode, and the service that governs sandboxed solution execution is called SharePoint 2010 User Code Host in the Windows Services dialog box on front-end web servers. This reflects an earlier name for what are now called sandboxed solutions.

  • Farm solutions are deployed on the front-end web servers by a farm administrator. These solutions have full access to the server object model and are not subject to usage limits.

Object Model for Solutions

Solutions can be administered by using the object model in SharePoint Foundation. This includes upgrading, retracting, and deploying. You can also set usage limits and define solution validators for sandboxed solutions programmatically through the object model.

Object Model for All Solutions

Object Model for Sandboxed Solutions

XML Used for Solutions

A solution is configured by using a solution manifest with the file name manifest.xml. The solution manifest is stored at the root of the solution package. This file defines the Features, site definitions, resources, and assemblies to include with the solution package. A file that is not included in the solution manifest will not be processed in any way. A sample solution manifest could look like the following.

<Solution SolutionId="SolutionGuid" xmlns="https://schemas.microsoft.com/sharepoint/">
  <FeatureManifests>
    <FeatureManifest Location="FeatureLibrary\feature.xml"/>
  </FeatureManifests>
  <TemplateFiles>
    <TemplateFile Location="ControlTemplates\Template.ascx"/>
  </TemplateFiles>
  <RootFiles> 
    <RootFile Location="ISAPI\MyWebService.asmx">
  </RootFiles>
  <Assemblies>
    <Assembly DeploymentTarget="GlobalAssemblyCache" Location="ms.samples.sharepoint.myFeature.dll"/>
  </Assemblies>
</Solution>

When you create a solution package, you can also create a DDF file that maps the location of the files on disk and the files in the solution package. We recommend that you use the SharePoint development tools in Microsoft Visual Studio 2010 to create SharePoint Foundation solutions. A sample DDF file could look like the following.

;
.OPTION EXPLICIT     ; Generate errors 
.Set CabinetNameTemplate=MySolutionFile.wsp 
.set DiskDirectoryTemplate=CDROM ; All cabinets go in a single directory
.Set CompressionType=MSZIP;** All files are compressed in cabinet files
.Set UniqueFiles="ON"
.Set Cabinet=on
.Set DiskDirectory1=Package
build\manifest.xml manifest.xml
build\MySolutionFile\feature.xml MySolutionFile\feature.xml
...

Building Block: Features

Building Block: Web Parts

Building Block: SharePoint 2010 Content Types

More Information About Solutions

Solutions Overview

Sandboxed Solutions in SharePoint 2010

Sandboxed Solutions Resource Center | SharePoint 2010