Skip to main content

Cloud

Wrap Your Content Type Feature in a SharePoint Solution

Features are a great way to package and manage the modules that you write for SharePoint; however, they are not the best mechanism for deploying your modules into SharePoint. To deploy a feature, you must copy its content into the 12 hive, install it with stsadm commands, recycle your IIS pools, and then activate the feature in the site or site collection in which you want to use it. This can be cumbersome for features that you want to use on multiple servers.

For deployments, you should package your features, assemblies, and artifacts in a SharePoint Solution. A SharePoint Solution is nothing more than a CAB file with a renamed extension. From this point of view, it may be a good idea to learn something about the CAB SDK, but you can get away with knowing only the fundamentals. The power of SharePoint Solutions is that you can easily deploy your features across servers in your farm, you can version your Solutions, and you can manage the Solution packages easily. For the small amount of work involved in creating the Solution files, you will gain a lot in manageability.

This article will take our Visual Studio content type project from the previous post and wrap it up into a SharePoint solution. Once again, this article is focused on the step by step procedures in making the Solution; I do not spend a lot of time on the concepts. If you would like to know more about the concepts, and you should, then you need to check out the WSS SDK documentation and the CAB SDK documentation – both are available on MSDN.

1. Create a Deployment folder

I like to keep my projects tidy, so using a folder to hold my SP Solution files just comes naturally to me.

2. Create a manifest.xml file

Add a new xml file in the deployment folder called ‘manifest.xml’. Add a solution tag to define the solution. Create a GUID with the GUID tool and strip off the { } from the string after you paste into place. Since this solution packages a content type feature, you only need to add a feature manifest tag that points to the feature.xml file. Note: The feature manifest tag is very picky. It must take the form of featurenamefeature.xml any other format will result in an error when you attempt to deploy the solution.

3. Create a wsp_structure.wsp file

Add a new text file in the deployment folder called ‘wsp_structure.ddf’: The filename is arbitrary but wsp_structure is nicely self-documenting. The top part of the file defines the formatting for the wsp (cab) file. Take special note of the CabinetNameTemplate line, this defines the filename of the wsp file that the make command will create.

The second half of the file, starting with the manifest line, defines the structure of the cab file. It may interest you to know that a cab file is a zip file, therefore you can validate the output by opening the wsp file with winzip or any other archiving software. You’ll notice that each line contains two parts. The first part is the relative path to the file in your Visual Studio solution from the deployment folder. The second part is the path of the file in the cab file. Since the manifest file is in the deployment folder and it should exist at the root of the cab, this directive looks a little weird with the ‘manifest.xml manifest.xml’ structure. On the other hand, the other files start with a .. to move up one folder from the deployment folder, then they reference the files. As well each feature file starts in the cab from the feature name: see note in step 2 about features being picky.

4. Make the wsp file

Open a command prompt and navigate to your deployment folder. Run the following make command to create a wsp from the files you created earlier.

makecab /f wsp_structure.ddf

Recall that you can open the resulting wsp file in WinZip or other archiving software to view the contents of the cab file

Watch a demo of this procedure.

Now you have your feature bundled up into a nice SharePoint feature package. In my next posting, I will discuss how to deploy this solution into your SharePoint installation and activate the content type feature in a site.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dave Scheele

More from this Author

Follow Us
TwitterLinkedinFacebookYoutubeInstagram