tags:

views:

22

answers:

1

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?

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

crocpulsar