ekvalizer
ekvalizer

Reputation: 148

How to run post build events after custom target?

I have some commands in post build events that i cannot move to targets and i need the post build events to run after custom target that i created. I have custom target CustomTargetthat depends on default target Build.

<Target Name="CustomTarget" DependsOnTargets="Build">
<!--Execute some commands-->
</Target>

i've changed default target in .csproj from Buildto CustomBuild

<Project ToolsVersion="4.0" DefaultTargets="CustomTarget" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--...-->
</Project>

And code from post build events is still executed before CustomTarged. Is there some way to execute post build events after all targets defined in DefaultTargets="" project section?

Upvotes: 3

Views: 1663

Answers (1)

LoLance
LoLance

Reputation: 28216

Try using script like:

  <Target Name="CustomTarget" BeforeTargets="PostBuildEvent">
    <!--Execute some commands-->
    <Message Text="This is custom target"/>
  </Target>

According to the log: The vs will execute custom target before post-build-event.

enter image description here

Upvotes: 7

Related Questions