views:

1249

answers:

2

Hi,

I would like to programmatically add a custom site template (.stp file) to a MOSS team site collection as part of my build process. Can anyone point me towards the best way to do this?

Thanks, MagicAndi.

+2  A: 

It looks like a simple batch file calling the STSADM tool with the -AddTemplate parameter is one option for this. The command is:

stsadm -o addtemplate -filename c:\template.stp -title "Template Title" -description "Template Description"

You can also delete an existing template using the command:

stsadm -o deletetemplate -title "Template title"

See this article for further details

MagicAndi
+2  A: 

A way of doing this with a feature would be to use the File element. STP files live in /_catalogs/wt so this type of feature will upload the file.

Update: More details in http://stackoverflow.com/questions/1532642/create-feature-to-upload-site-template-file-stp-in-moss/1536817#1536817 but for completeness here is the elements.xml:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"&gt;
    <Module Name="TeamSiteTemplate" List="111" Url="_catalogs/wt">
     <File Url="TeamSiteTemplate.stp" Type="GhostableInLibrary">
      <Property Name="LanguageDisplay" Value="English" />
      <Property Name="Version" Value="3" />
     </File>
    </Module>
</Elements>
Alex Angas
Hi Alex, I'm interested in pursuing this, but I have been unable to get the site template appearing in the gallery when depolying the feature. Could you provide a sample elements.xml file? Thanks. +1
MagicAndi
Alex, Thanks, accepted as the answer!
MagicAndi