tags:

views:

42

answers:

2

Is there a way to run a certain target after all other targets have been run regardless of their success or failure?

try...finally equivalent in MsBuild is related, but only deals with a small group of targets. I need something for the whole package with dozens of sub builds.

A: 

There is no straight forward way of doing this. Usually in MSBuild it is hard to know the actual order of targets, only the relative order. What are you trying to do with this target?

Sayed Ibrahim Hashimi
+1  A: 

Maybe if you wrapped things in a top-level target using one or more CallTargets, then you could use an <OnError .../> task to run a final target?

<Target Name="CompleteBuild">
  <CallTarget Targets="Target1"/>
  <CallTarget Targets="Target2"/>
  <CallTarget Targets="FinalTarget"/>

  <OnError ExecuteTargets="FinalTarget"/>
</Target>
Ross Johnston