16.7 Deploying Features using the Solution Framework 493
Chapter 16
ity and increases the likelihood of surviving future upgrades and service
pack releases.
16.7 Deploying Features using the Solution
Framework
The WSS 3.0 solution framework provides a method for collating the various
components that comprise a solution and packaging them together into a
solution file. The solution file is basically a cabinet-based format, with a .wsp
extension instead of a .cab extension. Once the solution file is created, the
solution file can then be used to deploy the contained functionality to a
SharePoint farm. Chapter 11 introduced the concept of the solution frame-
work and described several techniques that you can use to create a .wsp file. If
your solution file requires internal directories, you must use the
Make-
CAB.exe
technique, because Microsoft Visual Studio .NET does not support
creating cabinet files with internal directories. When working with Features
and custom applications in Visual Studio, you create a folder hierarchy that
mimics the
TEMPLATE\FeatureS and TEMPLATE\LAYOUTS folder hierarchy,
which means that you will be working with internal directories; therefore,
the
MakeCAB.exe technique is the method you should use to create your
solution files. Building a solution file using the
MakeCAB.exe involves first
creating a Feature project, then adding the solution manifest file to the
project, copying the files to the SharePoint directories, creating a .ddf file,
and then running MakeCAB.exe to create the solution file (.wsp). The solu-
tion file can then be deployed to the SharePoint farm using stsadm.exe. Let’s
walk through each of these steps using our Hello World example:
1. Using Visual Studio 2005 create a new empty project.
2. Create two folders at the root of the project, named TEMPLATE
and WSP.
3. Add two subfolders to the TEMPLATE folder, named FeatureS
and LAYOUTS.
4. Open the FeatureS folder and add another subfolder named Hel-
loWorld
5. Open the HelloWorld folder and add two XML files named Fea-
ture.xml and AddMenu.xml
6. Add the XML listed in Figure 16.13 to the Feature.xml file,
replacing the GUID with your own unique identifier. You can use
the Visual Studio Create GUID tool for this.
7. Add the XML listed in Figure 16.14 to the AddMenu.xml file.
494 16.7 Deploying Features using the Solution Framework
8. Open the LAYOUTS folder and add another subfolder named
CustomApps.
9. Open the CustomApps folder and create a new Windows Form
(.aspx page) with some simple Hello World text. Save the file as
HelloWorld.aspx.
10. Navigate to the root of the solution and create a new XML file
named manifest.xml.
11. Add the XML listed in Figure 16.26 to the manifest.xml, replac-
ing the
SolutionId GUID with your own unique identifier.
Once again, you can use the Visual Studio Create GUID tool
for this.
12. At the root of the solution, add a new text file and rename the file
HelloWorld.ddf.
13. Add the text listed in Figure 16.27 to the HelloWorld.ddf file.
The files used in the Feature should be referenced by stating both
the source path and the destination path to the files.
Figure 16.26
Manifest.xml.
Figure 16.27
HelloWorld.ddf.
16.7 Deploying Features using the Solution Framework 495
Chapter 16
14. At this point, the content of your Visual Studio project should be
similar to that shown in Figure 16.28.
15. Navigate to the root of the solution and create an install.bat file.
16. Add the code listed in Figure 16.29 to the install.bat file.
17. From the Project menu, click <project> Properties.
18. Navigate to the Build Events tab and enter the commands shown
in Figure 16.30 in the post-build event command line.
19. Save and build the project.
20. Exit Visual Studio.
The install.bat file copies all the Feature and custom application files to
their appropriate directory in SharePoint and creates the solution file using
Figure 16.28
Visual Studio
Project Layout
Figure 16.29
Install.bat
Get Microsoft SharePoint 2007 Technologies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.