Another way of dealing with this was suggested in the blog entry http://blogs.msdn.com/aaronhallberg/archive/2007/11/05/how-to-fail-a-build-when-tests-fail.aspx
I modified the code suggested there to make sure also that the files are not copied to the drop location if the unit tests fail.
<
Target Name="AfterTest"><!--
Refresh the build properties. --><
GetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"
Condition=" '$(IsDesktopBuild)' != 'true' ">
<
Output TaskParameter="TestSuccess" PropertyName="TestSuccess" /></
GetBuildProperties><!--
Set CompilationStatus to Failed if TestSuccess is false. --><
SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"
CompilationStatus="Failed"
Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' "/>
<
SetBuildProperties TeamFoundationServerUrl="$(TeamFoundationServerUrl)"BuildUri="$(BuildUri)"
SkipDropBuild="true"
Condition=" '$(IsDesktopBuild)' != 'true' and '$(TestSuccess)' != 'true' "/>
</
Target>