tags:

views:

20

answers:

2

I would like to add a build target to the BuildDependsOn, but I want it to only affect release builds. How do I do this in MSBuild?

A: 

I think you can just add

Condition="'$(Configuration)'=='Release'"

to the <Target>.

Brian
What if it is a predefined target that i can not edit, such as "Package"?
Peter Moberg
Then I think I like @madgnome's answer.
Brian
+1  A: 

Add a condition when you override the BuildDependsOn property :

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
...
<BuildDependsOn Condition="'$(Configuration)' == 'Release'">
  BeforeBuild;
  CoreBuild;
  AfterBuild;
  NewBuildTarget;
</BuildDependsOn>
madgnome
Works fine. Thanks!
Peter Moberg