Note: Visual Studio 2010 SP1 / MSBuild 4.0
I'm going crazy over this bug, I cannot understand why Visual Studio is behaving this way. I'm writing a custom .targets
file for my projects in a particular solution. I've edited the .csproj
file to have:
<Include Project="..\MyTargets.targets" />
After Microsoft.CSharp.targets
near the bottom of the file. The idea is that this targets file will inject actions to be performed by modifying the _____DependsOn
properties just like how PostSharp integrates itself.
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.
In the command line, my targets run. From visual studio (even using clean/rebuild), my targets do not run.
I've hooked BuildDependsOn
to run my targets like this:
<PropertyGroup>
<BuildDependsOn>
MyTargetGoesHere;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>
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.
So here I'm getting desperate. I put a BLARING SYNTAX ERROR in my targets file. MSBuild explodes, Visual Studio compiles the project successfully.
Microsoft.Common.targets
?To summarize the comments above, changes to imported project files do not trigger a reload, nor do changes to the importing project cause a reload of the imports. A solution file reload is needed to capture changes made in an import.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With