Wednesday, 16 November 2011

Deploying old version .stp templates into SharePoint 2010

I've been working on migrating an existing WSS 3.0 customization to a new SharePoint Foundation 2010 environment today. Most of the stuff was pretty straightforward (some web parts, web services, a few event handlers, ...), but there was one thing that didn't work out as planned.

I deployed STP file using with STSADM Command.

Now, while STP site templates are no longer supported, STP list templates should still work in SharePoint 2010. Unfortunately things were a bit trickier than I expected them to be.

As a test I started with uploading one of the original STP's to the template catalog (_catalogs/lt). No problem so far, but when I tried to create a list based off that template I got the following error:


after much searching i decided that SharePoint 2010 will not support to STP files.

As this wasn't an option, I decided to delve deeper into the STP file. As you might know, these STP files are just renamed CAB files. This means you can safely rename them again to .CAB and extract their contents ... which I did.

Doing so revealed that my STP/CAB file only contained a single file: manifest.xml. This file contains the definition of your list: its fields, contenttypes, views, ...
To have some data to compare to, I created a new, custom list in SharePoint 2010 and exported it as an STP template. Once again I renamed the file to .CAB and viewed its contents ... and there was much rejoicing.

It turned out that the SharePoint 2010 STP had the same content as the WSS 3.0 STP: just a single manifest.xml. A quick diff between the two manifest.xml files revealed that they're both quite similar and that there's a ProductVersion element in both files.
In the WSS 3.0 version, this element has a value of 3 ... but in the SPF2010 version, it has a value of 4. Could it be solved this easily?

Guess it was. I changed the value of the ProductVersion element in the original manifest.xml to 4 and repackaged it into a CAB. Renamed the CAB to STP and uploaded it again in SPF2010 and behold ... no more errors when creating lists from that template!

Summary
So if you need to migrate list templates STP's from SharePoint 2007 to 2010, you could try the following:
    1. Rename the original .STP to .CAB
    2. Extract its manifest.xml to a local folder (lets call it {workingfolder})
    3. Search for the ProductVersion element. This should have a value of 3 Change its value to 4
    4. Repackage the manifest.xml into a .CAB. I've done this by using makecab.exe in the C:\Windows\System32 folder
    Syntax: makecab.exe {workingfolder}\manifest.xml {workingfolder}\{template-name}.cab
    Change the generated cabinet's extension from .CAB back to .STP and upload it into the _catalogs/lt

Another way, Create new CAB project using with Visual Studio 2010.
File-->New Project-->select CAB project and Enter Project name here. by right clicking on the CAB project from Solution Explorer click on add and select manifest.xml file. just build the solution. .CAB file will be genrate in Projects Debug folder.Renamed the CAB to STP and uploaded it again in SPF2010 and behold ... no more errors when creating lists from that template!

No comments:

Post a Comment