title: AfterTargets failures don't fail msbuild run
body: <p>In my solution, some project have tasks that need to run at the end, such as copy files to various places.  We implement that with <code>AfterTargets="Build"</code>:</p>
  
  <pre><code>&lt;Target Name="CopyStuff" AfterTargets="Build"&gt;
      &lt;Copy SourceFiles="..." DestinationFolder="..." /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>If works. However, when building the solution (not the individual project!), if the copy fails, we get a red build warning, but msbuild (and therefore TFS build) succeeds:</p>
  
  <pre><code>&gt; msbuild /t:clean;build my.sln
  (...)
  (in red...) error MSB3021: Unable to copy file (...)
  
  &gt; echo %errorlevel%
  0     &lt;&lt;&lt;&lt;&lt;&lt;&lt; This means succeeded
  </code></pre>
  
  <p>To my understanding, that's because msbuild thinks that as long as the major "Build" target passed, everything passed too.</p>
  
  <p>Our workaround - Change target to <code>BeforeTargets="AfterBuild"</code>, which puts my target inside the Build target. However, this requires knowledge of the content of "Build" target, and may not work for other project types.</p>
  
  <p>Question:</p>
  
  <ol>
  <li>Is there a way to get <code>AfterTargets="Build"</code> failures to fail solution builds?</li>
  <li>If not, is there a way to automatically validates that people didn't add <code>AfterTargets="Build"</code> into their projects?</li>
  </ol>