Rory Primrose

Learn from my mistakes, you don't have time to make them yourself

View project on GitHub

TeamBuild - Custom build steps

Posted on April 8, 2009

I’ve been working with team build a fair bit over the last month. Yesterday I was bouncing through the MSDN documentation during my MSBuild travels and I came across a very handy build task. The BuildStep task allows you to create custom entries in the build report.

Take the following build target for example:

<Target Name="RunIntegrationTests">

  <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
             Name="Running integration tests"
             Message="Updating integration test configuration">
    <Output TaskParameter="Id"
            PropertyName="IntegrationTestsBuildStepId" />

  <CallTarget Targets="UpdateIntegrationTestConfiguration" />

  <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
             Message="Executing integration tests" />

  <CallTarget Targets="ExecuteIntegrationTests" />

  <BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
             Status="Succeeded" />


The BuildStep tasks have allowed the build report to include custom steps that are being executed. In this case, it is reporting on the progress of running integration tests.


You can also see that this report contains a custom build step for working with Sandcastle documentation.

This is a very easy to use task that adds rich information to your build reports. It is especially useful for when custom targets fail. Take the case of automated deployment that occurs before running integration tests. If the target is invoked by the inbuilt test targets (probably by overriding AfterTest), then it will be unclear which part of the build broken if the deployment target fails without trawling through the build log. With custom build steps, the report can identify that deployment broke rather than because of running tests.