Let's say I have three targets A, B and C.
C depends on B.
B depends on A.
If I run msbuild /t:C mybuildfile.xml
, it will execute target A, B and C in order.
How do I set up to make sure C and B won't get executed if there is anything failed in A?
<Target Name="StopBuild">
<Message Text="An error has occurred, build stopped." />
</Target>
<Target Name="A">
<OnError ExecuteTargets="StopBuild"/>
</Target>
<Target Name="B" DependsOnTargets="A">
</Target>
Ok, I figured out this by myself. Use the code above, if target A fails, it will go to StopBuild specified in OnError task. For more on how msbuild handles errors, go to http://en.csharp-online.net/MSBuild:_By_Example%E2%80%94Dealing_with_MSBuild_Errors
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