title: StyleCop MS Build magic? Who is calling the StyleCop target?
body: <p>In our project files we are using StyleCop and are running it during the build process. We've modified our project files to include the StyleCop targets like so:</p>
  
  <pre><code>&lt;Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /&gt;
  &lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" /&gt;
  &lt;Import Project="..\..\Tools\Microsoft\StyleCop\v4.3\Microsoft.StyleCop.targets" /&gt;
  &lt;!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  &lt;Target Name="BeforeBuild"&gt;
  &lt;/Target&gt;
  &lt;Target Name="AfterBuild"&gt;
  &lt;/Target&gt;
  --&gt;
  </code></pre>
  
  <p>The question is why does this work? Who is calling the StyleCop target defined in the Microsoft.StyleCop.targets file?</p>
  
  <p>As far as I can tell, the only target being run when you start the build, is the "Build" target. I can't find any references to the "StyleCop" target anywhere outside the Microsoft.StyleCop.targets file. So again, why is it being called?</p>
  
  <p>The reason I want to know is because it would be cool if we could do something similar for our own custom tasks. So instead of editing all of our 78 csproj files, we could just import our own general target like:</p>
  
  <pre><code>&lt;Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /&gt;
  &lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" /&gt;
  &lt;Import Project="Common.targets" /&gt;
  </code></pre>
  
  <p>And then just import StyleCop in that  file instead, along with all our other tasks that need to be done on a per project basis.</p>
  
  <p>Please help me understand.</p>