Importing documents to Document Libraries with Mavention Import Document Library Contents
Recently I showed you how you can import Lists and their data into your SharePoint Project using the Mavention Import List Instance extension. As you can imagine supporting list data is only half of the story, so to complete it another extension became available. Find out how to import documents from Document Libraries into your SharePoint project using Mavention Import Document Library Contents.
Last week we discussed how test data can help you test your SharePoint solutions and how you can import list data into your SharePoint Project for repeatable deployment. In my articles I covered only list data. However, as we all know, many SharePoint solutions include not only Lists but also Document Libraries and their data. So in order to be really productive you have to have a solution to cover both types of lists.
List Items and Files in Document Libraries are not quite the same from the deployment point of view. In order to provision List Items to a List you have to use the ListInstance element with all the data specified in the Data element. On the other hand to provision a document to a Document Library you have to use a Module and include not only the metadata but also the document itself.
Importing documents into SharePoint Project with Mavention Import Document Library Contents
Mavention Import Document Library Contents is an extension for the Visual Studio 2010 SharePoint Developer Tools which is very similar to the Mavention Import List Instance extension I presented previously.
After installing the extension a new option called Import Document Library Contents is added to the context menu of all Document Libraries in the Server Explorer.
After you click the option the contents of the selected Document Library will be imported to your SharePoint Project.
Important: For this to work you have to have a SharePoint Project open and active in Visual Studio 2010.
During the import process, the extension will create in the active SharePoint Project a new Module called after the selected Document Library. All files will be downloaded and included in the project structured just as they were in the selected Document Library.
Together with downloading the files and including them in the active SharePoint Project, the Mavention Import Document Library Contents extension will update the Element Manifest so that all files can be provisioned to a Document Library.
The only thing left for you to do is to add the imported Module to a Feature and once you activate it, all files from the imported Module should be provisioned to SharePoint.
Tip: As you might have noticed the extension imports all files with all available properties. To keep the imported files clean you should remove all unnecessary files (such as List Forms) and properties. In my next post I will show you how you can modify the XSLT we used previously for cleaning List Instance data, to clean up unwanted document properties in a Module.
And this is it! Using the Mavention Import Document Library Content extension you can import Documents from a Document Library into you SharePoint Project with a single mouse click.
Download: Mavention Import Document Library Contents from Visual Studio Gallery.