.net – Trapping Error Status in MSBuild


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
  ForEach item CallTarget Target=RunTest ContinueOnError=true
  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: How do I get Team Build to show test results and coverage for xUnit.net test suite?

Best Solution

Go grab 1.5 Beta. We fixed this by introducing the ExitCode output parameter to our xunit MSBuild task!