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;



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






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


<Target Name = "BuildNumberOverrideTarget" >


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




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