techblog

TFS 2012–Configure Automatic SharePoint Build Process–Part1

Dec 11, 2012 by Christoph // 3 Comments

Team Foundation Server 2012 provides great features supporting automation of processes during a application lifecycle. This blog post wants to give a short introduction to automate the build process for SharePoint 2010 solutions. 

Generally, the following topics will be covered within this and the following blog posts:

  • TFS Build Process & Templates – short introduction (<—here you are)
  • Integrating SPDisposeCheck
  • Integrating FxCop (coming soon)
  • Integrating StyleCop (coming soon)

 

TFS Build Process & Templates – short introduction

TFS 2012 uses Workflow Foundation 4 to manage build processes. The build workflows are declaratively described in XAML files and can easily be extended or changed.

With the creation of a new Team Project, a new folder “BuildProcessTemplates” is added to the project. The files are stored and versioned like all other source code files in the project. The following items are created automatically:

  • AzureContinuousDeployment.11.xaml (used to deploy against Azure –> info)
  • DefaultTemplate.11.1.xaml (used for “normal” builds)
  • LabDefaultTemplate.11.xaml (used to bring in Lab Environments –> info)
  • UpgradeTemplate.xaml  (used for older versions of TFS, makes more calls to MSBuild, less to WF)

Because we are developing for a SharePoint 2010 environment and we are starting on a green field, we are using DefaultTemplate.11.1.xaml as our template for a new build process.

 

Creating new Build Process

Usually, you start by copying an existing build process template to modify it to your special needs. I simply started by creating a new build process definition by copying the existing DefaultTemplate.11.1.xaml file. The option appears during the creation of a new build definition:

image

The file will be stored next to the other templates in the “BuildProcessTemplates” folder. Afterwards you can open the Workflow in Visual Studio by double clicking the XAML file. Make sure you click “Collapse All” at the beginning… Winking smile

You will be presented with the following workflow. The details are explained below.

image

1. Get the build (GetBuildDetail Activity)

In this first step, the details about the build are being requested from the agent. The interface IBuildDetail describes the properties the resulting variable will provide. You can access the properties via the BuildDetail-variable within the workflow, like BuildDetail.DropLocation.

2. Update drop location

In this sequence, the drop location will be calculated and set. The new build will be stored into this newly created subfolder. The folder name is created as follow:

BuildDetail.DropLocationRoot + BuildDetail.BuildDefinition.Name +  BuildDetail.BuildNumber

3. Run on agent

This is the build process itself. Variables will be initialized, the workspace gets configured for a new build,  source code is compiled and tests get executed. Take a look inside this sequences since this is the most interesting part for later changes.

4. Check in Gated Changes for CheckInShelveset Builds

If there was no error during build and tests, the gated changes are checked in into the repository. This prevents developers from checking in changes that cannot be compiled or will not pass the tests. More information about gated check-ins are available here.


3 Comments to “TFS 2012–Configure Automatic SharePoint Build Process–Part1”

  1. Jarda Krecek

    I’m a big promoter of TFS and have been using it in its entirety since version 2008.

    This week I for the first time needed to set up a SharePoint build machine. I found number of guides how to do it with VS2010 but none with VS2012. Your articles are great but talk about the process and not about the build machine/server itself.

    Would you be able to advise whether the set up (no SharePoint 2010 server installed on the build machine) is the same for VS 2012 and TFS 2012 or whether you need to do something different on the machine hosting the Build agent?

    Thanks a lot for any help. I’ve been clutching straws for days now.

    Reply
    • Christoph

      Hello Jarda,
      thank you for the feedback and the comment.
      As far as I tested on my Virtual Machines you do not have to do anything different to setting up a 2012 Build Agent then to set up a 2010 Build agents to compile SharePoint 2010 projects. The Script to collect the DLLs works the same way, and you will only need the appropriate frameworks to be installed on the agents as well as on a 2010 Build Agent. Let me know if you experience any specific issues here, so I will try to reproduce on my environment.
      Regards

      Reply

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Copyright © 2012 techblog All Rights Reserved.

The posts on this weblog are provided “AS IS” with no warranties, and confer no rights. The opinions expressed herein are personal and do not represent those of my employer.

Designed & Developed by ThemeElephant