Deploy Content Files to SharePoint Using SharePoint.DesignFactory.ContentFiles
June 25, 2012 4 Comments
Visual Studio SharePoint projects allow us to create modules to deploy these kind of files but it has a big drawback. When you do it, the files are deployed as “file definitions” – ghostable on the libraries. If a user customize the files, any new deployment will not update the instance on your site, only the file definition. If you want to see the updated version of the file you should go to SharePoint Designer and reset the specific file to its definition.
This is pretty bad and makes lots of people confused on why the file wasn’t updated.
I was trying to find a solution for this issue when a found a blog post by Serge van den Oever explaining the installation of a very interesting extension to Visual Studio 2010 to solve this issue. It is called SharePoint.DesignFactory.ContentFiles.
The extension allows you to:
- deploy content files from your Visual Studio to your local machine using the SharePoint API or to remote machines using the SharePoint client API.
- map folders on your solution to document libraries and special folders on a SharePoint site so you can deploy files to different locations.
- deploy files checking them out, in, publishing and approving it.
- deploy only files that have changed since the last deployment.
- customize the commands to deploy your solution – check documentation for details.
To install it follow the steps on the article SharePoint.DesignFactory.ContentFiles – Installation. The extension was built using the NuGet tool for Visual Studio. You need to have NuGet installed on your Visual Studio before running the extension. It also needs the MME extension to allow the tool to create custom menus on the project and items right-click menu.
After the installation, your Visual Studio project should contain some extra items:
- _MachineConfiguration folder: this folder contains Powershell scripts to tell the extension where to deploy the files. By default it will look for a script called default.ps1, then for one with the machine name or for a custom one if specified when the deploy command is called.
- _Tools folder: this folder contains batch files, Powershell scripts, reference DLLs ,documentation and other support files used by the extension.
- Mappings.xml: file used to map folders from the Visual Studio project to the document libraries on the SharePoint site.
- packages.config: Nuget configuration file to tell it to load the extension.
The installation worked just fine for me. I had only to check and tweak a few items to make it work.
After the installation is done, just check if you have a DLL named VSMenuManager.SharePoint.DesignFactory.ContentFiles.dll on your solution folder.
Edit the mappings.xml file to make sure you have all mapped folders created on your Visual Studio project otherwise the deployment will fail.
Create a copy of the Sample.ps1 file on the _MachineConfiguration folder with the name Default.ps1. Configure it with your machine’s web application URL and the settings for the deployment type (object model or client object model), user name, password and claims authentication usage.
After that just add the files you want to deploy to the folders and deploy all files to your web application. The output window can show you the progress of the deployment:
The documentation provides a very good insight on how to use and configure the extension and can be very useful. It can be found under the _Tools\Documentation folder.
If you need to create custom Configurations to deploy to different environments you can do that by following the steps on the Configuration part of the documentation.
In order to get my custom configurations to work I had to edit the Deploy.cmd and the Redeploy.cmd to accept thew configuration name as a parameter.
I added the %1 parameter by the end of line 2 on both files and it worked just fine.
You should test and see how much easier is to deploy content files to SharePoint 2010!
Thanks Serge! The SharePoint.DesignFactory.ContentFiles is really awesome!!!