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

Comments

  • Anonymous
    June 16, 2010
    The comment has been removed

  • Anonymous
    June 16, 2010
    Hi AWG -  You could use   Set-ExecutionPolicy Unrestricted   to allow ANY script to run.  But if you do this, I would suggest setting it back afterwards. Mike Morton - Visual Studio Program Manager

  • Anonymous
    June 17, 2010
    A more secure way to do this would be to click the "Unblock" button in the properties of the script after you have downloaded it.  This will make the file appear as if it came from a local or trusted location.  By doing this, you can leave your ExecutionPolicy set to RemoteSigned. Mike Morton - Visual Studio Program Manager

  • Anonymous
    December 01, 2010
    Seems to be incomplete, so far I also need these: Microsoft.SharePoint.IdentityModel.dll Microsoft.SharePoint.Linq.dll

  • Anonymous
    February 14, 2011
    We also did require the in GAC. Microsoft.Web.Design.Server

  • Anonymous
    March 23, 2011
    Thanks for the script! We needed to include several more in the script to ensure all our projects would build...should be most of the big ones. "Microsoft.IdentityModel.dll", "Microsoft.Office.Server.dll", "Microsoft.Office.SecureStoreService.dll", "Microsoft.Office.Server.UserProfiles.dll" "Microsoft.SharePoint.Client.dll", "Microsoft.SharePoint.Client.Runtime.dll", "Microsoft.SharePoint.IdentityModel.dll", "Microsoft.SharePoint.Linq.dll", "Microsoft.SharePoint.Publishing.dll", "Microsoft.SharePoint.Taxonomy.dll" Also it seems that the TestSharePoint14 function returned true when only Office 2010 was installed. It looks like a machine that truly has SP2010 installed the registry key to look at is: HKLM:SOFTWAREMicrosoftShared ToolsWeb Server Extensions14.0SharePoint

  • Anonymous
    October 16, 2015
    Please let me know if anybody has this powershell as it has been removed from the gallery

  • Anonymous
    October 22, 2015
    The comment has been removed