Trapping Error Status in MSBuild

Posted by Ruben Bartelink on Stack Overflow See other posts from Stack Overflow or by Ruben Bartelink
Published on 2009-06-29T16:30:40Z Indexed on 2010/03/21 7:01 UTC
Read the original article Hit count: 590

As part of some build automation of running xUnit.net tests with MSBuild, I'm running into a case where I need to loop over a batch of items.

Inside the loop, I need to detect whether an iteration failed, but I want to continue executing regardless. Then after the batched bit, I need to know whether one or more errors have occurred in order to report the outcome to TeamBuild.

IOW, in pseudocode:

Task Name=RunTests
  CreateItems
  ForEach item CallTarget Target=RunTest ContinueOnError=true
  CombineNUnitResults
  Report success/failure

Task Name=RunTest
   XUnit item

I'm hoping this can be achieved without a custom task (or hacking the xunit.net MSBuild task as Jonne did). (But willing to use MSBuild Community or Sdc tasks)

And @BradWilson: I this is isnt possible to do cleanly, I'll be looking for Jonne's change a la the NUnit task to also make it into the xunit task

See also: http://stackoverflow.com/questions/517560/how-do-i-get-team-build-to-show-test-results-and-coverage-for-xunit-net-test-suit

© Stack Overflow or respective owner

Related posts about msbuild

Related posts about exit-code