index > Team Foundation Server - Build Automation > Team Build extensions

Team Build extensions


Hello!

I need a perform some custom operations if build solutions in my Team Build Type completed succesfully and all tests was succseeded. How can i do this? What variables or build properties should I use in the choose conditions?

Thank you in advance,

Olga

olgaF

This is actually rather complicated to directly detect within MSBuild - the TestToolsTask (which is responsible for actually running your tests) has ContinueOnError true, which converts all errors into warnings such that the build can continue even when tests fail. This means that you cannot distinguish test success / failure by the Targets which get executed. There are no properties which get set on test failure within MSBuild either, so there's nothing to include in conditions, etc.

You can, howevber, distinguish the case you are interested in in code by writing a custom task. There is a property in the BuildData class returned from the GetBuildDetails web method called GoodBuild that is set to true when compilation and tests succeed and false otherwise. This value is set in the AfterTest target, so if you override a target that occurs after this one, you should be fine. I would suggest AfterEndToEndIteration - this will already weed out cases where compilation has failed, since this target only gets executed when compilation is successful. You would want something like this in TfsBuild.proj:

<UsingTask TaskName="MyNamespace.HandleCompilationAndTestSuccess" AssemblyFile="MyAssembly.dll"/>

<Target Name="AfterEndToEndIteration">

<HandleCompilationAndTestSuccess TeamFoundationServerUrl="$(TeamFoundationServerUrl)" BuildUri="$(BuildUri)" />

</Target>

Then, in your HandleCompilationAndTestSuccess task's Execute method, you can check the value of GoodBuild with some code like this:

TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(TeamFoundationServerUrl);

BuildStore buildStore = (BuildStore)tfs.GetService(typeof(BuildStore));

if (buildStore.GetBuildDetails(BuildUri).GoodBuild)

{

// Do custom logic here to handle compilation and test success.

}

Note that this assumes you have defined properties in your task named TeamFoundationServerUrl and BuildUri. Hope this helps!

-Aaron




http://blogs.msdn.com/aaronhallberg
Aaron Hallberg
This works, thank you!
olgaF

I was looking over this solution and it looked as if it was just what the doctor ordered, unfortunately it seems that the property "GoodBuild" doesn't exist...

I'm using the 2006.04 VS2005 SDK, with Microsoft.TeamFoundation.Build.Common.dll built 10/03-2006 01:04, I even analysed Microsoft.TeamFoundation.Build.Proxy.BuildData with Lutz Reflector and was unable to find any reference to the property "GoodBuild" which was referenced in the sample...

Anybody have any ideas what might be wrong?

poulrh

Ouch - sorry about that. I was mistaken about this - the GoodBuild property was added to the BuildData class subsequent to RTM and is not available in Team Build v1. There is, in fact, no way to retrieve the GoodBuild flag from Team Build in v1... We will certainly address this issue in a future release.

For now, however, there is a workaround for this particular problem (i.e. programmatically determining whether tests have passed for a particular build) - the GetTestResultsForBuild method, which returns an array of TestResultData objects, each of which has a RunPassed property that signifies whether or not the test run passed. Additional properties can even be used to retrieve the number of individual test failures, successes, etc.

I've posted an example on my blog that illustrates this workaround: http://blogs.msdn.com/aaronhallberg/archive/2006/09/21/764951.aspx.

Sorry for all the confusion,

Aaron




http://blogs.msdn.com/aaronhallberg
Aaron Hallberg
Well, that explains why I couldn't find it, thanks for the quick response and solution (tested and works) :)
poulrh
Tested and works..



I'm not a player, I just code a lot...
Alex Dresko
reply 7

You can use google to search for other answers

 

More Articles

Problem checking out binaries
Build Multiple TFS Projects not working
Invalid Drop Location
Custom Actions in a Team Build
How to pass parmeters to TFSBUILD at run time from another applic...
Why is the workspace deleted and recreated every time?
TF42056: The build service could not connect .... TF30063: You ar...
TfsBuild on buildserver fails after upgrade to RTM
Team System Builds and dropping an MSI
LastGoodBuildNumber
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

How to be sure if a build is running in …
Standard way to get BVT status.....
Automaticaly deployment to multiple envi…
Building 1 Soln with multiple web projec…
PropertyGroup and ItemGroup
Error with TFS build, but not when I man…
build process - replace text in config f…
Error while processing Code Coverage in …
How to schedule a build?
"Missing file" link error with…
I want to add dotfuscator automatica…
Having issues with Team Build
how can I build the VS2003 program…
Build Report
Data build

Hot Articles

Listing all files that changed between b…
Unit test results not getting copied to …
Unit Testing on a remote server
Building web applications in Build Server
BuildType for multiple solutions having …
Team Foundation Server Build Process
Build problem TF42004
How to make the build system not to sync…
Getting a project from another Team Proj…
Build Can't find references
How to publish (clickonce) a solution
Test not found in TFS build
why does it create wrong tmp files?
Property for CoreDropBuild target
Graphically Displaying Build Results

Recommend Articles

Can I set the OutputPath in a child proj…
Build Report
Changeset id and version id for file - s…
TF42056: The build service could not con…
Changing the drop location (overriding ?)
how to build a solution which mixed vb6 …
Assembly with Web Service is created dif…
Test results: No test resutls
Test coverage analysis report viewing
BUG: Serialization of Project type does …
Overriding a custom property in csproj f…
Independent builds
LastGoodBuildNumber
Partitioning Team Build Type
how to select which source to pull down …