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 . targets file is an MSBuild-compliant XML file you can add to a project to allow customizing the build process. A . targets file can have <Target> nodes containing MSBuild scripts.
If there are no initial targets, default targets, or command-line targets, then MSBuild runs the first target it encounters in the project file or any imported project files.
NET projects are defined in the Microsoft. Common. CurrentVersion. targets file which can be found in the MSBuild bin directory.
targets files that contain items, properties, targets, and tasks for common scenarios. These files are automatically imported into most Visual Studio project files to simplify maintenance and readability. Projects typically import one or more . targets files to define their build process.
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>
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?
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