This whitepaper explains how to build and publish Office solutions by using Team Foundation Server (TFS) Team Build 2010 without installing Visual Studio. Developers can create and build projects for Microsoft Office 2007 and Microsoft Office 2010 by using Visual Studio 2010. Later, these projects can be checked into TFS for source control, and then built and published with TFS Team Build without Visual Studio installed on the build computer. The steps described in the whitepaper are not needed if Visual Studio 2010 is already installed on the build computer.
You can use Team Build 2010 to build and publish Office projects created in Visual Studio 2010. To configure Team Build 2010, you must copy additional files and create registry keys that are required to build these projects. These files are always present on a machine with Visual Studio but are not present on a machine which has only the Team Build SKU installed.
.NET Framework
If you want to build projects targeting .NET Framework 3.5 and .NET Framework 4, make sure your Team Build System has both versions installed. You can download both versions of the .NET Framework from the .NET Framework Developer center: http://msdn.microsoft.com/en-us/netframework/default.aspx
Windows SDK for .NET Framework 4
Windows SDK is required to be installed for tools like GACUtil and SignTool. GACUtil will be used to install the Office development assemblies on the build system. SignTool is used to sign the deployment packages generated when you publish the Office project.
You can download the Windows SDK from the Windows Developer Center:
http://msdn.microsoft.com/en-us/windows/bb980924.aspx
Visual Studio Tools for Office 2010 Runtime
The Visual Studio Tools for Office 2010 Runtime redistributable is required to build any Office development project developed in Visual Studio 2010.
You can download Visual Studio Tools for Office 2010 Runtime here: http://msdn.microsoft.com/en-us/library/bb608603(VS.100).aspx
Sample scripts are available to help automate the process of copying the appropriate DLLs and creating the registry keys described in the instructions below. To use the scripts, you will need a computer with Visual Studio 2010 Professional or higher installed on it.
You can find the scripts and information on how to use the scripts here: http://go.microsoft.com/fwlink/?LinkId=188066
Office projects define their own custom build tasks in addition to the ones available in MSBuild. The following assemblies for the build tasks must be installed to the GAC on the build system in order to build the projects.
You can copy these DLLs from a system which has Visual Studio 2010 installed. The DLLscan be found under: “%Windows%\Microsoft.NET\assembly\GAC_MSIL”.
For information about using GACutil to install the DLLs to the GAC on the Team Build system, see:
http://msdn.microsoft.com/en-us/library/ex0ss12c(VS.80).aspx.
Office Projects define their own custom targets file: Microsoft.VisualStudio.Tools.Office.targets
The file can be found on a computer with Visual Studio 2010 at the following location:
%ProgramFiles(x86)%\MSBuild\Microsoft\VisualStudio\v10.0\OfficeTools\
Copy the file to the same location on the Team Build computer. Additionally if you want to use MSBuild 64-bit to build Office projects then you can copy the targets files to the 64-bit Program Files directory:
”%ProgramFiles%\MSBuild\Microsoft\VisualStudio\v10.0\OfficeTools\”
Copy all DLLsfrom the following Reference Assemblies locations on a computer with Visual Studio 2010 to the Team Build system.
Copy the Office Primary Interop Assembly DLLs from the following location on a computer with Visual Studio 2010 to the Team Build system.
If you want the Team Build system to generate a setup.exe capable of installing pre-requisites, you can copy all files from the following location on a computer with Visual Studio 2010 to the same location on the Team Build system.
The following registry keys are required to build projects targeting .NET 3.5 on the team build system. Create these sub-keys under the following registry key:
For 32-bit machines:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx]
For 64-bit machines:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\ v2.0.50727\AssemblyFoldersEx]
| Subkey name | Default value |
| VS10VSTOCommonPIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Common\\" |
| VS10VSTOOffice12PIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Office12\\" |
| VS10VSTOOffice14PIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Office14\\" |
| VSTA 3.0 v10.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTA30\\v10.0\\" |
| VSTA 3.0 v9.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTA30\\v9.0\\" |
| VSTO 4.0 v10.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTO40\\v10.0\\" |
| VSTO 4.0 v9.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTO40\\v9.0\\" |
The following registry keys are required to build projects targeting .NET 3.5 on the team build system. Add Sub-keys Under the following registry key:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx]
| Subkey name | Default value |
| VS10VSTOCommonPIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Common\\" |
| VS10VSTOOffice12PIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Office12\\" |
| VS10VSTOOffice14PIA | "C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Visual Studio Tools for Office\\PIA\\Office14\\" |
| VSTA 3.0 v10.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTA30\\v10.0\\" |
| VSTA 3.0 v9.0 Reference Assemblies | "C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTA30\\v9.0\\" |
| VSTA 3.0 v8.0 Reference Assemblies | @="C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTA30\\v8.0\\" |
| VSTO 4.0 Reference Assemblies | @="C:\\Program Files\\Reference Assemblies\\Microsoft\\VSTO40\\v4.0.Framework\\" |
These are the minimum configuration options that must be set in order to build and publish an Office Project.
Project Settings
If you build or publish a project from Visual Studio 2010 at least once, these settings are automatically applied to the .vbproj or .csproj project file. However if you haven't published your project once before trying to build it on the team build computer, you must set the following project properties manually.
For more details on these properties, see http://go.microsoft.com/fwlink/?LinkId=183196
If the signing certificate selected in step 2) is password protected you may see an error:
“Cannot import the following key file: The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user’s personal certificate store.”
MSBuild cannot automatically import the certificate into the certificate store on the Team Build computer. Instead, the certificate must be imported manually before you can use it for signing.
To import the certificate manually on the Team Build computer:
After the project properties are configured, the solution can be checked into TFS source control and a new build definition can be created for that project.
.jpg)
.jpg)
.jpg)
.jpg)
.jpg)
.jpg)
| /target:publish | Will call the publish target for the VSTO project to generate the publish package |
/property:PublishDir= "MyServer\Drops\ VSTOSolution\Publish\\" | Specifies the directory where the publish output will be copied after it has been generated. Important Note: Make sure the directory path specified ends with a trailing "\\" |
The build definition is now configured. Whenever this build definition is triggered it will build the solution drop the build output to the drop location and the publish output of the solution to the PublishDir location if it is specified in the MSBuild arguments.
| Steps | |
| 1 | Install Team Build software |
| 2 | Install Windows SDK to get GACUTIL and SignTool. |
| 3 | Install Visual Studio Tools for Office 2010 Runtime |
| 4 | Install Custom Build Tasks and Targets
|
| 5 | Copy Reference Assemblies
|
| 6 | Copy Primary Interop Assemblies
|
| 7 | Copy Bootstrapper Packages
|
| 8 | Add registry keys under
|
| 9 | Specify the following MSBuild Arguments in the Build definition to publish the Office Project: /target:publish /property:PublishDir="MyServer\Drops\ Publish\\" |