See IDs of all available Site Definitions
While working on SharePoint solutions once in a while you need to create custom Site Definitions. It’s not easy to work with Site Definitions: they can easily get very complex and are almost impossible to debug. Unfortunately there are situations when you cannot avoid using custom Site Definitions. Is there anything we could do to make it easier to work with Site Definitions?
One of the things you really have to be careful about is defining the ID of a Site Definition. According to the Windows SharePoint Services 3.0 SDK the Site Definition ID should be an integer greater than 10.000. In scenario’s when you would be deploying your solution to a dedicated it’s not a problem. Just pick a random number greater than 10.000 and everything should be okay. The problems begin when you know that your solution will share the server with other applications.
Just recently I’ve found myself spending way too much time on debugging the custom Site Definition I was working on. The only error I got was:
The site / could not be created. The following exception occured: The template you have chosen is invalid or cannot be found.
Neither the SharePoint log nor the Event Viewer provided me with any more explanation. I have tried virtually everything when it struck me: are there by any chance other Site Definitions with the same ID on the web server? You can guess the answer.
As I hate to waste my time and try to learn my lessons, I have created a tool which creates for you an overview of all Site Definitions installed on the server.
OCDInstalledSiteDefinitions is a custom STSADM extension which allows you to view the IDs of all installed Site Definitions. This command is similar to Gary Lapointe’s gl-enuminstalledsitetemplates extension. While Gary focused on returning the list of Site Templates available within the particular Site Collection, I have chosen another approach: in particular to retrieve the ID of all Site Definitions deployed to the web server.
OCDInstalledSiteDefinitions takes two optional parameters. By default it scans the 12\TEMPLATE\1033\XML directory for the available Site Definitions. If you’re using SharePoint in other language than US English, you can pass the ID of that language using the lang parameter:
stsadm –o ocdinstalledsitedefinitions –lang 1043
So far I have never faced a SharePoint setup where SharePoint has been installed to other location than the default C:\Program Files\Common Files\Microsoft Shared\web server extensions\12. If you however work on a different setup you can pass the path to the 12 directory using the path parameter:
stsadm –o ocdinstalledsitedefinitions –path D:\SharePoint\12
OCDInstalledSiteDefinitions is a freeware utility and you can use it without any restrictions. You’re installing it on your machine on your own responsibility.
Download: OCDInstalledSiteDefinitions (348KB, MSI)