Manually Creating Solutions in SharePoint Foundation
Applies to: SharePoint Foundation 2010
This topic provides some background information about solution packages in Microsoft SharePoint Foundation and how to manually create them.
Microsoft Visual Studio includes tools that simplify (and largely automate) the creation and configuration of solution packages. We recommend that you use these tools. This topic is provided only for background information, for the rare cases in which you might need to edit one of the files outside the Visual Studio tools, and for developers who do not have Visual Studio.
SharePoint Solution Packages
A solution package is a cabinet file that has a .wsp file name extension. It always includes a manifest file, and it can also contain some or all of the following components:
Site definitions (onet.xml, webtemp*.xml, and possibly default.aspx)
Code access security policies
Modifications to web.config
Template files and root files, which can include the following:
application pages (*.aspx)
Resource files (for example, *.doc or *.xls)
user controls (*.ascx)
Non-SharePoint assemblies, such as custom managed class libraries. These can be deployed in conjunction with the following:
Safe control entries
Feature definitions and their corresponding element definitions and files. Some of the things that can be in a Feature are the following:
Web Part files (*.webpart, *.dwp)
List instances and list templates
Content types and custom field types
site pages (*.aspx)
Assemblies for Web Parts or other custom SharePoint Foundation classes. These can be deployed in conjunction with the following:
Safe control entries
Solution files have a hierarchical structure—a manifest file is at the root—while Feature, resource, or site definition directories are contained in subdirectories.
Files for a particular Feature or site definition should be placed in that Feature or site definition's subdirectory.
The directory structure inside the .wsp file determines the final directory structure on the front-end web server file system. However, the directory structure within Solution Explorer that is produced by the tools of Visual Studio is generally not an exact match for the directory structure of the front-end web server.
To manually create a solution package
Create a solution manifest.xml file.
The solution manifest (always called manifest.xml) is stored at the root of a solution file. This file defines the list of Features, site definitions, resource files, Web Part files, and assemblies to process. It does not define the file structure—if files are included in a solution but not listed in the manifest XML file, they are not processed in any way.
Following is the structure of a manifest.xml file.
<Solution SolutionId="4AFC1350-F354-4439-B941-51377E845F2B" xmlns="https://schemas.microsoft.com/sharepoint/"> <FeatureManifests> <FeatureManifest Location="FeatureLibrary\feature.xml"/> </FeatureManifests> <TemplateFiles> <TemplateFile Location="ControlTemplates\Featurelibraryform.ascx"/> </TemplateFiles> <RootFiles> <!-- These files go into the 12\ directory and can be used for Web services and global resources --> <RootFile Location="ISAPI\MyWebService.asmx"> </RootFiles> <Assemblies> <Assembly DeploymentTarget="GlobalAssemblyCache" Location="ms.samples.sharepoint.myFeature.dll"/> </Assemblies> </Solution>
In addition, you can add a DwpFiles element to specify .webpart or .dwp files, or a ResourceFiles element to specify resource files, site definitions, application resources, and code access security policies.
If you have Features in the package, each of them has a feature.xml file. For each Feature element manifest file (elements.xml) in the Feature, add an ElementFile tag that points to the Feature element manifest.
Create the solution package—the .wsp file.
Because the solution file is essentially a .cab file, use the makecab.exe tool to create the solution package. The makecab.exe tool takes a pointer to a .ddf file (Diamond Directive File), which describes the structure of the .cab file. The format of a .ddf file is basically in the same style as the .inf file—you declare a standard header and then enumerate, one file per line, the set of files according to where they live on disk, separated by where they should live in the .cab file.
; .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 ...