I started using the SharePoint Visual Studio Project Templates from CodePlex and extended the original solution to:

  • Use seperate SharePoint Project and SharePoint Deployment templates; this supports packaging multiple SharePoint Projects (assemblies and artifacts) into a single SharePoint Deployment Package (.wsp file).
  • Modified scripts that generate the manifest.xml and cab.ddf to support packaging additional SharePoint Artifacts (site definitions, root files).

Using these templates on several of my customer engagements has gotten their development teams into the habit of packaging their SharePoint solution properly for deployment.  I have attached the templates and an example using code samples from Inside Microsoft Windows SharePoint Services 3.0.

SharePoint Project Template 

The SharePoint Project template mimics the 12 hive folder structure for working with SharePoint artifact files.  I used 12 as the root folder because certain SharePoint artifact files may live outside the TEMPLATE folder (eg. Resources).
12
|--TEMPLATE
   |--FEATURES
   |--...
|--Resources

I find working with the 12 hive structure far more intuitive than using the Visual Studio 2005 Extensions for Windows SharePoint Services that also does not provide complete control over the generated solution package.  I have used my templates to re-package the code samples from Inside Microsoft Windows SharePoint Services 3.0.

The DLLS folder structure is used for deploying the compiled assembly to the Web Application BIN directory or the Global Assembly Cache and defining <SafeControl> and <CodeAccessSecurity> settings in Web.config for the assembly.
DLLS
|--CodeAccessSecurity
|--GAC
|--SafeControls

  • DLLS: compiled assemblies copied to this folder will be packaged for deployed to the Web Application BIN directory by the SharePoint Deployment project.
  • CodeAccessSecurity: Contents of <CodeAccesSecurity>.xml files in this folder will be added to the solution manifest by the SharePoint Deployment project.
  • GAC: compiled assemblies copied to this folder will be packaged for deployed to the Global Assembly Cache by the SharePoint Deployment project.
  • SafeControls: Contents of <Assembly>.dll.xml files in this folder will be added to the solution manifest by the SharePoint Deployment project.

The SharePoint Project template contains a Post-build event command-line to:

  1. Optionally copy the project output to the DLLS or GAC folder.
  2. Copy the 12 and DLLS folder structure to a SharePoint Deployment project path.

Please review Readme First for how to configure the project template.

SharePoint Deployment Template 

The SharePoint Deployment template contains 2 scripts to automate generation of the solution manifest (manifest.xml) and solution package (.wsp):

  • CreateManifest.vbs: This script creates the solution manifest file by enumerating the 12 and DLLS folder structures.
  • CreateCabDDF.vbs: This script creates the DDF file used to generate the solution package.

The Scripts folder contains deployment scripts that call the Stsadm command-line tool to deploy, upgrade and retract the solution package.  These deployment scripts can be extended to perform additional installation / un-installation tasks required by the solution (e.g. create new site collection using site definition deployed by the solution package).

The SharePoint Deployment template contains a Post-build event command-line to:

  1. Clean-up project output directory; output of SharePoint Deployment is .wsp and deployment scripts.
  2. Execute CreateManifest.vbs to generate solution manifest file (manifest.xml).
  3. Execute CreateCabDDF.vbs to generate DDF file (cab.ddf).
  4. Run makecab.exe to generate the solution package (.wsp).
  5. Copy the deployment scripts to project output directory.

Please review Readme First for how to configure the project template.