title: multiple build rules using vc2010 and msbuild
body: <p>I'm managing a C++ project in VS2010 and want to have ALL .cpp files run through an external tool before going to the C++ compiler.  All signs seem to indicate this is possible.  See, for example, <a href="http://msdn.microsoft.com/en-us/library/dd293705.aspx" rel="nofollow">here</a>.</p>
  
  <p>Since this will happen over multiple projects, it makes sense to put this functionality in a property sheet and then just importing this property sheet everywhere.  Before I touched the property sheet, it looked like this in its entirety:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
    &lt;PropertyGroup&gt;
      &lt;_ProjectFileVersion&gt;10.0.30319.1&lt;/_ProjectFileVersion&gt;
      &lt;ExtensionsToDeleteOnClean&gt;...&lt;/ExtensionsToDeleteOnClean&gt;
      &lt;CustomBuildBeforeTargets&gt;ClCompile&lt;/CustomBuildBeforeTargets&gt;
    &lt;/PropertyGroup&gt;
    &lt;ItemDefinitionGroup&gt;
      &lt;ClCompile&gt;
        &lt;AdditionalIncludeDirectories&gt;...&lt;/AdditionalIncludeDirectories&gt;
        &lt;ForcedIncludeFiles&gt;%(ForcedIncludeFiles)&lt;/ForcedIncludeFiles&gt;
      &lt;/ClCompile&gt;
      &lt;Link&gt;
        &lt;AdditionalDependencies&gt;...&lt;/AdditionalDependencies&gt;
      &lt;/Link&gt;
        &lt;Outputs&gt;...&lt;/Outputs&gt;
      &lt;/CustomBuildStep&gt;
    &lt;/ItemDefinitionGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>As per the above linked document, I have added the following lines:</p>
  
  <pre><code>&lt;Project&gt;
    &lt;PropertyGroup&gt;
      ...
      &lt;CustomBuildBeforeTargets&gt;ClCompile&lt;/CustomBuildBeforeTargets&gt;
    &lt;/PropertyGroup&gt;
    ...
    &lt;ItemGroup&gt;
      &lt;CustomBuild Include="*.cpp"&gt;
        &lt;Message&gt;Running Custom Build Step&lt;/Message&gt;
        &lt;Command&gt;dummy&lt;/Command&gt;
        &lt;Outputs&gt;dummy&lt;/Outputs&gt;
      &lt;/CustomBuild&gt;
    &lt;/ItemGroup&gt;
  &lt;/Project&gt;
  </code></pre>
  
  <p>This appears to have no effect, and my custom build tool never runs before ClCompile.  I have tried various ways of moving things around and renaming tags (the Xml editor complains that CustomBuild isn't even valid according to the schema, for example), but nothing works.  </p>
  
  <p>What am I doing wrong?  </p>