Clean up after nant build failures
I'm looking for my nant build script to be able to clean up after itself if a build go开发者_高级运维es wrong. I'm looking for something resembling the following execution:
Target= Software.Build
Target= Software.Build.Success *(depends on Software.Build succeeding)*
Target= Software.Build.Failed
I am looking for a solution that if the Software.Build target fails then Software.Build.Failed will be executed e.g. to e-mail someone that the build failed in some way, otherwise Software.Build.Success will be run to allow the build script to continue.
Is this even possible with nant? If so, could anyone point me to a suitable article/solution?
Or if you have global data to be cleaned up, you can use the NAnt OnFailure event.
<property name="nant.onfailure" value="failure" />
<target name="failure">
<!-- Put your cleaning code in here -->
</target>
NAntContrib has a trycatch
task:
<trycatch>
<try>
<call target="Software.Build" />
</try>
<catch>
<call target="Software.Build.Failed" />
<fail message="build failed" />
</catch>
<finally>
<!-- execute everything that doesn't depend on success or failure -->
</finally>
</trycatch>
<call target="Software.Build.Success" />
精彩评论