title: Visual Studio Ignoring MSBuild file (csproj) Customizations
body: <p><em>Note: Visual Studio 2010 SP1 / MSBuild 4.0</em></p>
  
  <p>I'm going crazy over this bug, I cannot understand why Visual Studio is behaving this way. I'm writing a custom <code>.targets</code> file for my projects in a particular solution. I've edited the <code>.csproj</code> file to have:</p>
  
  <pre><code>&lt;Include Project="..\MyTargets.targets" /&gt;
  </code></pre>
  
  <p>After <code>Microsoft.CSharp.targets</code> near the bottom of the file. The idea is that this targets file will inject actions to be performed by modifying the <code>_____DependsOn</code> properties just like how <a href="http://www.sharpcrafters.com/postsharp" rel="noreferrer">PostSharp</a> integrates itself.</p>
  
  <p>After scratching my head at how my targets would not run I decided to run it in the command line with MSBuild and see the nicely formatted color output.</p>
  
  <p>In the command line, <strong>my targets run</strong>. From visual studio (even using clean/rebuild), <strong>my targets do not run</strong>.</p>
  
  <p>I've hooked <code>BuildDependsOn</code> to run my targets like this:</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;BuildDependsOn&gt;
      MyTargetGoesHere;
      $(BuildDependsOn)
    &lt;/BuildDependsOn&gt;
  &lt;/PropertyGroup&gt;
  </code></pre>
  
  <p>My first thought is that i've got the wrong file. I verified the file, it's the right one. Then I checked to see if it was stale. Let visual studio make some changes, saved, ran. Visual studio's new changes took effect, still didn't run my targets.</p>
  
  <p>So here I'm getting desperate. I put a <strong>BLARING SYNTAX ERROR</strong> in my targets file. MSBuild explodes, Visual Studio compiles the project successfully.</p>
  
  <ul>
  <li>What am I doing wrong? </li>
  <li>Does Visual Studio not use the MSBuild file? </li>
  <li>Does it call some super secret target instead of "Build" from <code>Microsoft.Common.targets</code>?</li>
  <li>Why would msbuild behave one way and studio another, I thought they were designed to work together...</li>
  </ul>