Tagging TFS builds from MSBuild

Here’s another integration between MsBuild and TFS that I didn’t know you could do - add tags to a build.

Tagging a build allows you to filter on a giant list of builds to see which ones match the criteria. In my case I wanted to check the exit code for nunit-console.exe and tag any builds where the exit code is non-zero (a problem) and positive (the number equals the number of tests failed for that test assembly).

Again, we use the weird tfs vso output syntax.



<Message Importance="high" 
    Text="##vso[build.addbuildtag]UnitTestsFailed" 
    Condition="@(NUnitExitCode) gt; 0" 
    />