Share via


How to customize the build process in Team Build?

Build process in Team Build is highly extensible. A custom step/task can be introduced at any build phase. The process of customization is very simple. I will illustrate this process with very simple example. Consider the scenario where a company want to use there own build numbering format. They do not want to use the default build numbering scheme. How should they customize the build process using Team Build?

 

First step is to implement the custom task. For example our client will implement simple task called BuildNumberGenerator. This task will generate a unique build number based on current time in milliseconds. Please note that the output of the task is the BuildNumber property. The attribute “Output” indicates that BuildNumber property is output of our custom task.

 

using System;

using Microsoft.Build.Utilities;

using Microsoft.Build.Framework;

 

namespace BuildNumberGenerator

{

    public class BuildNumberGenerator:Task

    {

        public override bool Execute()

        {

            m_buildNumber = DateTime.UtcNow.Ticks.ToString();

            return true;

        }

        private string m_buildNumber;

 

        [Output]

        public string BuildNumber

        {

            get { return m_buildNumber; }

        }

    }

}

 

After implementing and testing the custom task you need to define “Build Type” using Team Build client. The “Build Type” consists of TeamBuild.proj, VCOverrides.props, and WorkspaceMapping.xml files. Every “Build Type” is represented by a folder which contains the mentioned files. To know more about how to create “Build Type”, please refer this post.

 

After creating build type you need to customize the “Build Type” definition by plumbing your custom task. For our sample scenario, you need to checkout the TeamBuild.proj file. Add the following code in the file to plumb the task.

 

<!-- Add using task line just after import statement - - >

 

<UsingTask

            TaskName="BuildNumberGenerator.BuildNumberGenerator"

            AssemblyFile="BuildNumberGenerator.dll"/>

 

<! -- Override the target towards the end of proj file - - >

 

<Target Name = "BuildNumberOverrideTarget" >

    <BuildNumberGenerator>

            <Output TaskParameter="BuildNumber" PropertyName="BuildNumber"/>

    </BuildNumberGenerator>

</Target>

 

After plumbing the task, add your task assembly to the same location as TeamBuild.proj using hatteras commands (ht add BuildNumberGenerator.dll, ht checkin BuildNumberGenerator.dll).

 

Launch the build using Team Build client. You will get the next build marked with your custom build number.

 

Disclaimer: The information mentioned is for beta3 bits (releasing in September 2005).

Comments

  • Anonymous
    July 13, 2005
    Aaron Skonnard - Service Station column in MSDN Magazine

    I admit, I only skimmed it, but it looks...
  • Anonymous
    July 14, 2005
    Visual Studio Team System

    There’s a new Team System community site – TeamSystemRocks.com! ⊕
    Well,...
  • Anonymous
    June 01, 2006
    Best of the text i read about a problem.
  • Anonymous
    June 19, 2006
    Persone los pioneros non rabata. Great...
  • Anonymous
    September 22, 2006
    Why I get a random number like

    632945572233322189
  • Anonymous
    September 28, 2006
    The Team Build service in Team Foundation Server includes the current date in the build number by default....
  • Anonymous
    October 19, 2006
    The Team Build service in Team Foundation Server includes the current date in the build number by default.