During the last year I’ve been developing custom solutions for SharePoint 2007 for various customers and I’ve been evangelizing my approach for writing code which is easy to deploy and maintainable on your servers. Of course I used the best practices for building SharePoint solutions: making customizations available with Features and packaging those customizations and components in Solutions (WSP’s). Building SharePoint Features comes down to writing XML and the only tool Microsoft gave us developers was Notepad; of course I’m exaggerating a little bit: you can use Visual Studio as well, but still you have to write XML. Packaging SharePoint customizations into Solutions is even worse: a WSP file is actually a CAB file that you have to create by making use of the famous tool MakeCab. You need to feed the MakeCab tool a DDF file, which is a plain text file (not XML) describing the contents of the CAB. Besides the customizations themselves, you also need to have a Solution manifest, again a XML file, that tells SharePoint how everything should get deployed. Bottom line: for developer it’s quite hard to implement these best practices.
Microsoft acknowledges the issues that SharePoint developers are facing, they created the Visual Studio extensions for Windows SharePoint Services (VSeWSS). This is an extension on top of Visual Studio that adds some project and item templates to the development environment. These templates take care of building the feature XML files, the DDF for MakeCab and even the Solution manifest. Version 1.0 of those extensions were only good to use in demos and proof-of-concepts in my opinion: it was not possible to tweak the generated XML files or influence the creation of the Solution (e.g. web part DLL’s were always deployed to the GAC). Recently version VSeWSS 1.1 has been released with some very interesting new functionality; but still, in some scenarios want to have more flexibility and freedom. And maybe even more important, sometimes you want to use the shiny new Visual Studio 2008! (currently VSeWSS 1.1 only works with Visual Studio 2005)
Let me introduce you to the SharePoint SmartTemplates for Visual Studio! I’ve created (and I’m still creating) some templates for Visual Studio 2008 that allow me to create new Visual Studio projects for the typical SharePoint development tasks, that are configured like I want them to be configured. Typically my project looks like this:
- Solution
- Class Library Project
- *.cs files
- WSP folder
- 12 folder
- Template/features folder
- batch files to create the WSP
- Setup folder (contains installer)
I prefer to use the excellent WSPBuilder tool to quickly build the WSP file, and I use the SharePoint Solution installer to build a setup wizard for easy deployment. For example by using the SmartTemplates you can create a new Visual Studio project based on the web part template, it creates the folder structure, generates the feature XML files, generates an empty web part and configures the installer. So everything is in place to get started writing that code instead of worrying about how to package your code and get it deployed. If you want to see the web part template in action check this small screencast.
I’ve put the first version of the SmartTemplates on CodePlex in December and (without actually telling anybody) they have been download almost 1500 times. This week I created a new version which includes a second template for building a web part using the SmartPart. So you can now build a web part by making use of the user control technique, package it into real WSP, and get it deployed by making use of a setup wizard!
I the near future I’m going to add new templates for an empty Feature (with event receiver), Application page, event handler etc. If you feel like contributing to the SmartTemplates: drop me a line! It would be great if somebody could build a VB.NET version, and/or a Visual Studio 2005 version.