domingo, 5 de febrero de 2012

Build SharePoint Projects with TFS Team Build

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.

  • Install TFS Team Build
    If your build system already has TFS Team Build installed on it, you can skip this step. Otherwise, install and configure Team Build on your build system. Both Team Build 2008 and Team Build 2010 can build and package SharePoint projects created in Visual Studio 2010.
  • Install .NET Framework 4
    If you are using TFS Team Build 2008, you must install .NET Framework 4 because it is not installed by default. You can download .NET Framework 4 here:http://msdn.microsoft.com/en-us/netframework/default.aspx. After installing .NET Framework 4, update the build path of TFS to point to the location of .NET Framework 4 by doing the following:
    1. On the Build system, navigate to: \Microsoft Visual Studio 9.0\common7\IDE\PrivateAssemblies;
    2. Open the TFSBuildService.exe.config file using Notepad running as Administrator.
    3. In the file, find the MSBuildPath setting in the AppSetting section.
    4. Set the path value to the location of.NET Framework 4. (For example, C:\Windows\Microsoft.NET\Framework\v4.0.21116);
    5. In the Windows Services console, restart the Visual Studio Team Foundation Build Service.
  • Install Windows SDK
    Windows SDK is required to be installed for its GACUtil tool. This tool is used to install the SharePoint Tool assemblies on the build system. You can download the Windows SDK here: http://msdn.microsoft.com/en-us/windows/bb980924.aspx.  After you download the Windows SDK, install it. Note that the PowerShell script referenced at the end of this article eliminates the need for this step.
  • Install the DSL Assembly
    The domain-specific language (DSL) assemblies required to build SharePoint projects is included with Team Build 2010, so you can skip this step if Team Build 2010 is already installed on your build system.
    For TFS 2008, copy the following assembly from the development system and install it in the global assembly cache (GAC) of the build system using GACUtil:
           Microsoft.VisualStudio.Modeling.Sdk.10.0.dll
           Path:  C:\Windows\Microsoft.NET\assembly\GAC_MSIL\

    For information about using GACutil, see http://msdn.microsoft.com/en-us/library/ex0ss12c(VS.80).aspx.

  • Install the SharePoint Assemblies
    Since SharePoint projects reference SharePoint Server 2010 assemblies, those SharePoint assemblies must be present on the build system.
    One way to do this is to install the full SharePoint Server 2010 on your build system. An advantage of having SharePoint installed is that you can use it to deploy and test your SharePoint application immediately after generating the WSP file. Some drawbacks of having SharePoint Server 2010 installed are that it can degrade system performance, and it has increased system requirements (such as requiring a 64-bit CPU).
    Alternatively, you can just download the required SharePoint assemblies onto your build system. For either method, you will need the proper license of SharePoint on the build system.You can copy the following assemblies from the development system to the build system and put them in a Reference Assembly folder:
  • 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:

        On 64-bit systems:

  • HKEY_LOCAL_SYSTEM\SOFTWARE\Microsoft\Wow6432Node\.NETFramework\v2.0.50727\AssemblyFoldersEx\SharePoint14]@="<AssemblyFolderLocation>”

        On 32-bit system:

  • HKEY_LOCAL_SYSTEM\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\SharePoint14]@="<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

For information about how to build a SharePoint project, see the Team Build documentation
about setting up a build definition at: http://msdn.microsoft.com/en-us/library/ms181716.aspx
and queue in the build.

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.

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.

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 theCompilation 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.

 

Fuente:

http://msdn.microsoft.com/en-us/library/ff622991.aspx

No hay comentarios:

Publicar un comentario