Introduction
Microsoft Visual Studio 2010 provides a brand new set of tools for developing SharePoint applications. With these tools, developers can easily leverage the familiar Visual Studio environment and functionality to develop, package, deploy, and debug custom SharePoint solutions. Team development is also well-supported by these tools. You can check your SharePoint projects into Team Foundation Server (TFS) source control and build and package your projects in TFS Team Build. This article describes how to build SharePoint projects developed by the VS2010 using Team Build when neither Visual Studio 2010 nor SharePoint 2010 is installed on your build system. If Visual Studio 2010 or/and SharePoint 2010 are installed on the system, however, you can skip some of the steps below that patch the system with necessary dependencies.
1. Prepare the Build System
To build and package SharePoint projects, several components must be installed on your system.
- Microsoft.SharePoint.dll
- Microsoft.SharePoint.Security.dll
- Microsoft.SharePoint.WorkflowActions.dll
These files are located in the following folder on the development system:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI
It is recommended that you copy the SharePoint Server assemblies to the folder:
.. \Program Files\Reference Assemblies\SharePoint\
And then add the following registry entry:
HKEY_LOCAL_SYSTEM\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\SharePoint]
@="<AssemblyFolderLocation>”
If your SharePoint Projects refer to other SharePoint Server assemblies, copy them to the build system as well.
- Copy the SharePoint Tool Assemblies and Files to the GAC
The following assemblies must be copied to the GAC of the build system:
- Microsoft.VisualStudio.SharePoint.Designers.Models.dll
- Microsoft.VisualStudio.SharePoint.Designers.Models.Features.dll
- Microsoft.VisualStudio.SharePoint.Designers.Models.Packages.dll
- Microsoft.VisualStudio.SharePoint.dll
These files are located in the following folder on the development system:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\
You must also have the following custom target and tasks for build and package of SharePoint projects on the build system.
- Microsoft.VisualStudio.SharePoint.Targets
- Microsoft.VisualStudio.SharePoint.Tasks.dll
These files can be copied from ..\Program Files\MSBuild\Microsoft\Visual Studio\v10.0\
SharePointTools\ on the development system to the corresponding folder on the build system.
(For 64-bit systems, use “\Program Files (x86)” in the path above.)
If you also need localized versions of the files, you should also copy and install
the corresponding resource DLLs to the GAC of the build system:
- Microsoft.VisualStudio.SharePoint.Designers.Models.Features.resources.dll
- Microsoft.VisualStudio.SharePoint.Designers.Models.Packages.resources.dll
- Microsoft.VisualStudio.SharePoint.Designers.Models.resources.dll
- Microsoft.VisualStudio.SharePoint.resources.dll
And the following resource for the tasks should be installed on the build system too:
- Microsoft.VisualStudio.SharePoint.Tasks.Resources.dll
2. Build a SharePoint Project
3. Create a WSP package for the SharePoint Project
By default, building a SharePoint project in Visual Studio 2010 doesn’t generate a WSP package for the project. To generate a WSP package for your SharePoint project as part of the team build, you must include a parameter. To generate packages when building in TFS 2010, set the parameter /p:IsPackaging=True in the UI.
.jpg)
Figure 1 Team Build 2010 Build Definition UI
When you queue or start a build definition in TFS 2008, you can add the same parameter to activate the
package
task to the MSBuild command-line arguments property when you queue in a build.
.jpg)
Figure 2 Team Build 2008 Queue in Build UI
If you want the package generated every time the build definition is used, add the parameter to the build file (e.g. TFSBuild.proj) in TFS 2008.
4. Appendix
Procedure for setting up Team Build for SharePoint projects on TFS 2008 and TFS 2010
| Steps | TFS2010 | TFS2008 |
| 1 | Install Team Build software | Same as TFS2010 |
| 2 | Skip this step - TFS2010 already installs .NET Framework 4. | Install .NET Framework 4.0 and update build path of TFS |
| 3 | Install Windows SDK to get GACUtil if you don’t already have one on the build system | Same as TFS2010 |
| 4 | Skip this step - TFS2010 already installs the DSL assembly. | Install DSL Assembly Microsoft.VisualStudio.Modeling.Sdk.10.0.dll |
| 5 | Install the SharePoint assemblies: - Microsoft.SharePoint.dll
- Microsoft.SharePoint.Security.dll
- Microsoft.SharePoint.WorkflowActions.dll
If your project refers to other SharePoint assemblies, copy them to the build system too. | Same as TFS2010 |
| 6 | Install the SharePoint tools targets and tasks - Microsoft.VisualStudio.SharePoint.targets.dll
- Microsoft.VisualStudio.SharePoint.Tasks.dll
| Same as TFS2010 |
| 7 | Install the SharePoint tool assemblies: - Microsoft.VisualStudio.SharePoint.
Designers.Models.dll - Microsoft.VisualStudio.SharePoint.
Designers.Models. Features.dll - Microsoft.VisualStudio.SharePoint.
Designers.Models. Packages.dll - Microsoft.VisualStudio.SharePoint.dll
| Same as TFS2010 |
| 8 | Build and package the SharePoint projects. In TFS2010, this can be customized through the UI of the Build Definition. Under the Compilation category, in the MSBuildArguments field, add the following script: /p:IsPackaging=True | For TFS2008, when you queue or start a build, you can add the script to activate the package task in the MSBuild command-line arguments text box: /p:IsPackaging=True If you want the package be created every time the build definition is used, add the script to the generated build file. |
Script Support for Patching the Build System
Sample scripts are available to help automate the patching of the build system for SharePoint projects (see: http://go.microsoft.com/fwlink/?LinkId=188064). If SharePoint 2010 and Visual Studio 2010 are already installed on your developer system, you can run the script to collect all the necessary files in a folder. Then, copy this folder to the build system and run the script again to install the files to the proper locations.