Sharepoint Solution packages (WSP) are Microsoft Cabinet files, the file extension .wsp is generally used to distinguish these files as associated with Sharepoint solutions.
The two popular ways to create these files are to either use a Visual Studio cabinet project, or use the Microsoft Cabinet Software Development Kit
This post will be using the latter method.
The custom field solution in Visual Studio looks like this:
The files on the file system are in exactly the same structure, note also how the TEMPLATE folder and its subfolders are in the same structure as TEMPLATE in the 12 directory on the server.
A Diamond Directive File (DDF) file is used by the MAKECAB.EXE program to create a cabinet file containing all the files that are required by the Sharepoint Solution.
Just four files are required to deploy the Regex Custom Field created in the earlier post:
Manifest.xml
RegExTextField.ascx
fldtypes_RegExControl.xml
RegExField.dll
The DLL is the assembly, the xml is the field definition, and the ascx is the control template. These are files that are to be deployed on to the server running Sharepoint. The WSP deployment process will put these files in their relevant places on the file system (into the TEMPLATE folder in 12, and the GAC for the DLL). Note that if the deployment platform is a FARM of Sharepoint servers, by deploying this WSP we are ensuring that all files will be deployed in the relevant places on each server in the farm. The WSP framework also ensures that if new servers are added to the farm, these machines will also be updated with the relevant objects on their file system.
The only file that is not deployed is the Manifest.xml file, this is used to inform Sharepoint of the finer details of the deployment process.
The manifest file for the regex custom field project looks like this:
<Solution xmlns="http://schemas.microsoft.com/sharepoint/" SolutionId="E3F3F75B-E76D-4f6e-82C0-0827DB82F925">
<TemplateFiles>
<TemplateFile Location="ControlTemplates\RegExTextField.ascx" />
<TemplateFile Location="XML\fldtypes_RegExControl.xml" />
</TemplateFiles>
<Assemblies>
<Assembly Location="RegExField.dll" DeploymentTarget="GlobalAssemblyCache">
<SafeControls>
<SafeControl Assembly="RegExField, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9ba34c98dffd3009" Namespace="RegExField" Safe="True" TypeName="*" />
</SafeControls>
</Assembly>
</Assemblies>
</Solution>
Note: The SolutionId in the manifest file should be one generated with a GUID generator like GUIDGEN. The assembly references should contain references to the assembly generated by the source code. By strong naming this assembly the PublicKeyToken can be identified.
The manifest file contains references to the two file system objects, the Control Template, and the Field Definition, and their locations. The Assemblies section instructs Sharepoint to install the DLL to the GAC and to add a SafeControls section to the web.config of the Web Application to which this solution will be deployed.
For this simple WSP the DDF file (CABSettings.ddf) looks like this:
.OPTION Explicit
.Set CabinetNameTemplate="RegExField.cab"
.Set DiskDirectory1=
manifest.xml
;** REGEX Control Template
.Set DestinationDir=CONTROLTEMPLATES
..\TEMPLATE\CONTROLTEMPLATES\RegExTextField.ascx
;** REGEX Field Def
.Set DestinationDir=XML
..\TEMPLATE\XML\fldtypes_RegExControl.xml
;** DOCUMENT LIBRARY CODE
.Set DestinationDir=
..\bin\Debug\RegExField.dll
The DestinationDir in each case of the 12 directory objects is set relative to the 12/TEMPLATE folder. No DestinationDir is specified for manifest (as it has no destination directory, it is just used by the system), and the assembly, the assembly’s destination is specified in the manifest.
The files’ locations listed are relative to the Provisioning folder in the solution (where MAKECAB.EXE and the DDF are run from).
Assuming that MAKECAB’s path has been added to the environment variables, running makecab as follows will create the WSP file:
MAKECAB.EXE /f CABSettings.ddf
MAKECAB.EXE should give a friendly message describing compression, time elapsed and so on, but importantly how many files have been included in the cab. In this case four.
Note: This example makes a .cab file, an WSP is a cab file, Sharepoint cares not the slightest what its file extension is. To change it to output as a .wsp change the CabinetNameTemplate setting in the DDF file.
Sticking with the .cab file extension, the following file should have been created in the Provisioning folder:
RegExField.cab
It is worthwhile double checking the Paths of the files by inspecting the contents of the cab file.
This file needs to be copied to the Sharepoint server to be added to the Solution store and deployed to a site collection.
The solution can be deployed to the Sharepoint Server by using the STSADM command line tool:
(Assuming that STSADM ’s path has been added to the environment variables)
STSADM -o addsolution -filename RegExField.cab
STSADM -o deploysolution -name RegExField.cab -immediate -allowGacDeployment -force -url [URL of SiteCollection]
STSADM -o execadmsvcjobs
The custom field type should now be visible in the Create Column drop down of a Sharepoint List

No comments:
Post a Comment