Recently I have been working creating a series of Site Definitions for one of my employer’s client’s. The tool of choice (the best of a bad bunch?) for this is the SharePoint Solution Generator 2008, bundled with the Visual Studio 2008 Extensions for Windows SharePoint Services 3.0. The tool comes fitted with a few ‘gotchas’ – subtle annoyances that really make no sense and therefore are a tad tricky to find resolutions to. In the interests of saving other developers from pulling their hair out, here a couple that I have found:
Issue 1: You get an ‘Object reference not set to an instance of an object’ error when you deploy a Site Definition.
Resolution: Remove any comment tags <!– –>in your onet.xml document. I tried commenting out List elements in the Configuration –> Lists element of the onet.xml file and it threw the error. Deleting the line instead of commenting it out worked fine. Comment tags do not throw an error until you go to deploy the solution (no error when you are editing the XML in Visual Studio).
Issue 2: Can’t deploy a second site definition in the same site collection if it was also created by the Solution Generator
Resolution: Rename the SiteProvisioning feature. You will get a feature naming conflict if you deploy a second site definition that has been generated by the Solution Generator. Simply open the WSP view (I assume you are using the VSeWSS), rename the SiteProvisioning feature to something else and click the refresh button up the top of the WSP view to update the reference in the manifest.xml file.
Other:
- ALWAYS make sure you are using the latest version of the Solution Generator. You can get the latest version by downloading the latest Visual Studio Extensions for Windows SharePoint Services 3.0. Don’t forget to uninstall your old version before installing the new version as this also creates hassles!
- When you are building your site that you are going to run the solution generator over, don’t build it as the root site in a Site Collection. The Solution Generator will pick up all the lists that the Site Collection needs to run, like the User Information List. I’ve had hassles even if I deselect the lists when I go to create the Site definition with the Solution Generator
- Don’t select lists that are already a part of the site definition you are deriving from. Your site definition will deploy but you may get list naming conflicts when it goes to create your site. For example, if you create a site using the Team Site site definition, don’t select the document library, task list and announcements list that it creates when you are running your Solution Generator.
- Reconsider your need to use the Solution Generator, or to create site definitions! In reality, the Solution Generator creates working site definitions only for really simple sites. If you have done anything fancy to your site, chances are the site definition the Solution Generator generates will not work. The time you spend debugging the code the Solution Generator creates could be better spent doing one of two things:
- Creating a solution in Visual Studio utilizing the SharePoint object models to make the modifications to a site post-creation. I certainly would have more confidence in this approach and you can better approximate the time it will take to use this approach.
- Doing nothing – just use a Site Templates – if you can! Take the performance hit and the loss in a bit of functionality for a relatively pain free solution. There are a couple of blogs that explain the pros and cons of Site Templates vs. Site Definitions. Jeremy Thake provides a great explanation in his post titled “Site Features vs Site Templates vs Site Definitions“.
Hope that helps. If I find any more I’ll be sure to post them up. Let me know of your experiences using the Solution Generator by posting a comment below.
Tags: Customization, Design Tips, Development, MOSS 2007, Site Definition, Solution Generator 2008, WSS 3.0