Building Visual Studio SharePoint Projects using Team Foundation Build

With Microsoft’s introduction of the Visual Studio 2010 SharePoint Developer Tools and its continually growing support for team development, the SharePoint Developer Tools team has published an MSDN article on how to configure your Team Foundation Build server(s) to support both the building of Visual Studio SharePoint projects and the creation and validation of SharePoint deployment packages (.wsp).

The article outlines the steps needed for setting up both Team Build 2008 and Team Foundation Build 2010 server configurations.

Additionally, the team has also created a PowerShell script that will aid users in collecting and installing the required assemblies for build Visual Studio SharePoint projects. The steps to use the PowerShell script are quite simple.

First, download the .ps1 file from the MSDN Code Gallery and copy it onto a SharePoint Tools developer’s machine or any machine that has Visual Studio 2010 and SharePoint 2010 installed. Before you can execute the script, you need to enable the correct permissions. To do so, run PowerShell under administrator privileges and enter the following command:

Set-ExecutionPolicy RemoteSigned

Next, navigate to the directory where you copied the .ps1 script and enter the following command

.\ SharePointProjectToTfsBuildServer.ps1 –Collect

This will gather all the necessary files from the developer’s machine and copy them into a sub folder named “Files”. Copy this subdirectory, along with the PowerShell script onto the build server(s).

Finally, the last step is to tell the PowerShell script to install the files. Once again, we’ll need to enable the correct permissions to execute the script so again run PowerShell as an administrator and enter the following command:

Set-ExecutionPolicy RemoteSigned

Next we’ll do the same thing we did when we “collected” the required assemblies but instead of passing the “-Collect” parameter, we’ll pass it “-Install”, like so:

.\ SharePointProjectToTfsBuildServer.ps1 –Install

This moves all the files into the correct place and makes any other changes to the system, if needed.

Now you’re all set to begin building your Visual Studio SharePoint projects on your Team Build server(s). Consult the MSDN article for more information on how to correctly set up your build definition in TFS.

Scot Moorhead