Peter Moberg
Peter Moberg

Reputation: 3098

MSBuild BuildDependsOn target for release builds only?

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?

Upvotes: 1

Views: 1127

Answers (2)

Julien Hoarau
Julien Hoarau

Reputation: 49970

Add a condition when you override the BuildDependsOn property :

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
...
<BuildDependsOn Condition="'$(Configuration)' == 'Release'">
  BeforeBuild;
  CoreBuild;
  AfterBuild;
  NewBuildTarget;
</BuildDependsOn>

Upvotes: 4

Brian
Brian

Reputation: 118855

I think you can just add

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

to the <Target>.

Upvotes: 1

Related Questions