In my case I often create SharePoint sites and lists in a development environment or on a demo server, just to set up and verify the architecture and design. From that point I often have to sit down and start writing the actual feature, which involves some heavy Xml coding most of the times – now I have found a shortcut that will save me an awful amount of time.

Let’s say that you have created a list in your demo environment, with columns, views and everything. This list is then the target of your feature you are about to develop. Creating the manifests, list templates and instances are pretty easy, but creating the schema can be troublesome and/or time consuming. Today I found a sweet little custom STSADM command called OCDExportList. This custom command exports the list schema from a list in a SharePoint site to an .xml file. Similar functionality can be found in other SharePoint solution generators, but I prefer using STSDEV and for this situation the custom command is great!

To get the schema.xml and related .aspx files just write

.\STSADM.EXE -o ocdexportlist -url http://server/site -name listname -dir c:\temp\

Then all you have to do is reference the schema.xml file in your STSDEV solution.

If you don’t want to use the exported .aspx files in your feature, add the SetupPath attribute to the Form and View elements in the schema.xml

Form:

Form Type="DisplayForm" Url="DispForm.aspx" ...  SetupPath="pages\form.aspx"/>

View:

View DefaultView="TRUE" Url="AllItems.aspx" ... SetupPath="pages\viewpage.aspx">

Technorati tags: SharePoint, WSS, MOSS, STSDEV, STSADM