Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have created a list in sharepoint 2010 and want to somehow export the list definition for use in a feature in visual studio 2010. What is the best approach to getting the list definition?

share|improve this question

2 Answers 2

If you've created the list in the web interface, save the site as a template, which will download it as a WSP package. In Visual Studio, create a new project and select the project template which creates a project from a WSP file, it's somewhere under SharePoint in "New Project" template selection.

There you can dig out all the definitions for that site and pull out your List Definition for use elsewhere.

share|improve this answer
    
wsp files imports list instance not list definition. that's not what is asked about –  Jedistan Jun 25 '12 at 14:33
    
WSP can contain both list defs and instances. –  SPDoctor Jun 25 '12 at 14:41
1  
@SPDoctor - nope, if the list was initially created and customized though the browser, the wsp will contain a list instance using the list template originally used(most likely, 'custom list') and a custom schema attached. Not exactly the same thing but could work if the OP's users will not be creating new lists from these list definitions. –  Derek Gusoff Jun 25 '12 at 18:54
    
What I mean is that a WSP can contain both - of course what is in a particular WSP depends on how it was created. –  SPDoctor Jun 26 '12 at 11:56

If you just need to provision a customized list, James Love's solution above will do the trick. If you need to create actual list templates that users can use to create new lists off of, you'll need to create a new list definition.

The easiest way to do this is to get your content type from the wsp site template, add that into your Visual Studio project, and add a new item of type "List definition from Content Type", using the content type you just added.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.