title: Trapping Error Status in MSBuild
body: <p>As part of some <a href="http://jonnekats.wordpress.com/2009/05/07/integrate-xunit-tests-into-your-daily-team-build/#comment-7" rel="nofollow noreferrer">build automation of running xUnit.net tests with MSBuild</a>, I'm running into a case where I need to loop over a batch of items.</p>
  
  <p>Inside the loop, I need to detect whether an iteration failed, <em>but</em> 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.</p>
  
  <p>IOW, in pseudocode:</p>
  
  <pre><code>Task Name=RunTests
    CreateItems
    ForEach item CallTarget Target=RunTest ContinueOnError=true
    CombineNUnitResults
    Report success/failure
  
  Task Name=RunTest
     XUnit item
  </code></pre>
  
  <p>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)</p>
  
  <p>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</p>
  
  <p>See also: <a href="https://stackoverflow.com/questions/517560/how-do-i-get-team-build-to-show-test-results-and-coverage-for-xunit-net-test-suit">How do I get Team Build to show test results and coverage for xUnit.net test suite?</a></p>