From: Weintraub, D. <dav...@bo...> - 2006-10-27 17:59:55
|
You can use the Nant "nant.onfailure" property to specify the name of the task to run on a task failure: <property name="nant.onfailure" value="revert"/> The above will run the Nant task "revert" when a Nant task returns an error. You could then have the "revert" task do your cleanup. ________________________________ From: nan...@li... [mailto:nan...@li...] On Behalf Of Gage, Joshua SDR 2675 Sent: Friday, October 27, 2006 12:47 PM To: nan...@li... Subject: Perform task on error? or try/finally Hi all, I have a task which runs an external program. That program generates some output files to a specific folder. Once that is done I copy those files to our output folder and delete the program's output folder. <target name="doFoo"> <exec program="foo.exe"> <arg line="/o:./FooOutput"/> </exec> <copy todir="./ProjectOutput"> <fileset ....../> </copy> <delete dir="./FooOutput"/> <=== Would like this to run even if the <exec> fails </target> If the external program fails, I would like to delete its output folder to clean it up since those output files are not valid. Is there some way to specify that a sub-task should run even if a previous task failed? Can I create another target where I execute the program, then in the main target delete the folder and still have Nant record a failed build? Is there a try/finally type of construct? Thanks, - Josh |