Exporting List Definitions in a development environment using Visual Studio 2008

Visual Studio 2005 extensions for Windows SharePoint Services 3.0 (VSeWSS) ship with a useful tool called SharePoint Solutions Generator. One of its features I use most often is creating a List Definition based on an existing list. Since the CAML schema of a list isn't really straight-forward - especially if the list uses complex settings and multiple custom views it's almost undoable to create such schema manually. Another possibility could be using List Templates instead of List Definitions. List Templates are unfortunately impossible/difficult to customize and should be used, in my opinion, in SharePoint configuration scenarios when there is no other choice. SharePoint Solution Generator comes very useful if you want to work with List Definitions but you don't want to type all the CAML yourself.

VSeWSS has however one major flaw: it doesn't work on development environments using Visual Studio 2008.

First of all the extensions will not even install as the setup checks the Visual Studio 2005 dependency. Even bypassing the setup and copying the installed version of SharePoint Solution Generator to a development environment using VS 2008 doesn't work: SharePoint Solution Generator throws an exception during the start. The fact that there is no tool for exporting an existing list to a List Definition has suddenly become a serious risk in the project I'm currently working on. Installing VS 2005 next to VS 2008 might be a solution. I haven't tried it personally because it simply didn't seem right to me: installing a huge IDE in order to be able to run a tiny (yet very useful) utility.

While exploring the possible solutions I have found out that SharePoint Solution Generator exports lists to List Definitions using the /_vti_bin/owssrv.dll. The call is very simple: http://yoursite/_vti_bin/owssrv.dll?cmd=ExportList&List=<List GUID>. This call returns the contents of the Schema.xml file of a List Definition. The list forms (AllItems.aspx, NewForm.aspx, etc.) can be retrieved using the Files property of a list. Further research has proven unfortunately that the exported Schema.xml doesn't work: creating a list based on this schema results in an exception. Looking deeper into SharePoint Solution Generator I have noticed that the tool alters the exported Schema.xml after it has been exported. It's quite odd that the WSS team has created a functionality for exporting the Schema.xml which cannot be exported unless altered!

Eventually I have succeeded in wrapping it all together into a working package. I have created a custom StsAdm command called ocdexportlist (ocd stands for One Click Deployment - the development strategy we have designed and developed together with some custom tools. More about OCD coming soon). I will try to publish the command before I go to the Microsoft Office System Developer Conference 2008. Stay in touch for updates.

Technorati Tags: SharePoint 2007, SharePoint, MOSS, WSS, Development, Visual Studio 2008


comments powered by Disqus