Creating Advanced Solutions for SharePoint 2007
Creating a CAB File and Some Helpful Tools
After the creation of the manifest file, the next step is to compress all the required files into a CAB file. Microsoft provides the key software in the "Cabinet Software Development Kit," which can be downloaded from the Microsoft site, http://support.microsoft.com/kb/310618.
To construct a CAB file, apply the "Cabarc" tool with the syntax:
CABARC [options] command cabfile [@list] [files] [dest_dir]
- N: Create new cabinet
- L: List contents of an existing cabinet
- X: Extract files from a cabinet
And the support options are:
- -c: Confirm files to be operated on
- -o: When extracting, overwrite without asking for confirmation
- -m: Set compression type [LZX:<15..21>|MSZIP|NONE], (default is MSZIP)
- -p: Preserve path names (absolute paths not allowed)
- -P: Strip specified prefix from files when added
- -r: Recurse into subdirectories when adding files (see -p also)
- -s: Reserve space in cabinet for signing (for example, -s 6144 reserves 6 Kb bytes)
- -i: Set cabinet set ID when creating cabinets (default is 0)
To make a simple .wsp Solution file, utilize the following:
CABARC N mySolution.wsp file1.aspx file2.dll manifest.xml
This command creates the Solution file mySolution.wsp containing the files "file1.aspx", "file2.dll", and "manifest.xml" (bear in mind the "manifest.xml" file is obligatory), in a single folder, drawing on the default compression mode, MSZIP.
To make Solution files that deploy files to special directories in the 12 hive of SharePoint, it is essential that the directory structure within the WSP file is preserved relative to the 12 hive. For example, to deploy a Feature, the files need to be located in a "TEMPLATEFEATURES" directory in the WSP file. Figure 1 illustrates the directory structure for the files of a sample feature:
Figure 1: File structure for a Solution
In this case, where the file structure is preserved, the syntax to make the Solution_Test.wsp at the root of C: directory will be:
CABARC.EXE -p -P TemporaryJupiterMediaFeature n C:Solution_Test.wsp C: TemporaryJupiterMediaFeatureResources*.* C: TemporaryJupiterMediaFeature CTypes.xml C: TemporaryJupiterMediaFeatureFeature.dll C:Temporarymanifest.xml
This is considerably more complicated than employing a simple structure. To assist with the construction of the file, there is a gratis windows application that can be downloaded from www.gavd.net/servers/sharepointv3/spsv3_item.aspx?top=5&itm=431. This application asks for the files to be compressed and their location inside the 12 hive; after configurating the location and type of output (WSP or CAB), all the intricacies will be assumed by the application:
Figure 2: Making a .wsp file with the SolutionBuilder
There is also a Visual Studio 2005 Template that can be downloaded for free from http://www.codeplex.com/sptemplateland. This Template creates a Visual Studio 2005 Project that takes care of the construction of the .wsp file.
The litany of grievances regarding development and the installation process, and specifically deployment of custom-made software, with SharePoint Portal Server 2003 or Windows SharePoint Services 2.0 is legion. The tiresome process of manual copy-and-paste of files and the time-consuming construction of custom-installed programs were the only options available.
With the launch of SharePoint 2007 (MOSS and WSS) and the introduction of the SharePoint Solutions framework, in one sweep, there was a solution to these inadequacies. the framework ensures the deployment, activation, deactivation, and removal of the customizations, as well as deployment in all of the servers in the farm. It does this in a controlled and time-tabled manner, allowing for version organization and complete transparency for system administrators.
Solutions can be employed programmatically, from the user interface of the SharePoint Central Administration or using the administrators' tool "stsadm". The construction of the manifest file is efficient and orderly, and there are tools to assist in the construction and compilation of the final WSP file.
About the Author
Gustavo Velez is a MCSD Senior Application Developer for Winvision (http://www.winvision.nl), a Microsoft Gold Partner in the Netherlands. He has had many years experience in developing Windows and Office applications, and more than five years of daily programming experience with SharePoint. The author's articles—in English, Dutch, and Spanish—can be found in many of the leading trade magazines and he's pleased to be Webmaster of http://www.gavd.net/servers, the only Spanish-language dedicated SharePoint site. Spanish-language readers may want to consult the author's new book; Programación con SharePoint 2007.
Page 4 of 4