My First Experience with SPSource

Posted Monday, May 4, 2009 11:45 AM by CoreyRoth

If you pay attention to twitter at all, today you might have heard about a new tool on CodePlex called SPSource.  SPSource is a tool that reverse engineers existing Content Types, Site Columns, Lists and more on an existing SharePoint site.  This isn’t just a re-tweet style post that tells you its out there.  I actually took a few minutes today to try it out and so far I am very impressed.  Kyle Kelin and I have often talked about the need for a better tool that worked better than VSeWSS Solution Generator.  Already, I think this tool is it.  Finally you can design a content type in the UI and be able to extract it easily as a feature.

Downloading the tool from CodePlex, gives you an installer for the SPSource executable.  The tool is a command line app designed to be executed in a batch file.  To get started with the tool, you need to create a local 12 hive folder.  You can do this inside Visual Studio manually or with a tool like wspbuilder.  For my test purposes, I just created a 12 hive folder in a temp directory and started working.  Before you begin, you will need to create a folder to hold your feature as well as a simple feature.xml file.  The contents of the file don’t need to contain much, just some XML for deploying a simple feature.  The next thing you need to do is identify what you want to extract from your SharePoint.  In my case I wanted to extract some content types and a list template.  You then create a special XML file with the .spsource extension.  This uses the same syntax as any elements.xml file, but it is used to specify which items to extract from SharePoint.  The only thing you need to specify is an element such as ContentType or ListTemplate and the name.  It then uses this name to look up the resource in SharePoint and extract it.  Here is an example of what it looks like.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <ContentType Name="My Test Content Type" />

  <ListTemplate Name="My Custom List" />

</Elements>

SPSource will take this information and generate the XML files I need to deploy these items elsewhere.  You run SPSource with the following syntax.

spsource.exe –designsite http://my-moss-server/site

When the tool is executed, it will iterate through any subfolders looking for .spsource files.  When it finds them, it will create XML files representing the type of items you request (in my case a ContentType and a ListTemplate).  It will also update the Feature.xml file in that folder to point to any new .XML files it creates.  So far I have found the XML it generates to be very usable and way more accurate than what SPSolGen gives you. 

This tool is really nice.  I would like to see some more documentation for it, but I am sure that will come as the tool is developed more.  When you first install it, all you are given is a link to the CodePlex site in your start menu, so you are left a little bit wondering what to do next.  I would love to see more command line options such as just passing it a URL and it extracts the list template.  One thing I noticed is that it didn’t extract the ItemEventReceivers definition I had on my content type.  I am not complaining though since this tool already has the power to save me a ton of time in the future.

Great work @jthake and everyone else that worked on it.  Microsoft should have provided a better tool to do this years ago.  I am glad you all stepped up to fill in the gap.

Follow me on twitter.

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)