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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gage, Joshua SDR 2675
Sent: Friday, October 27, 2006 12:47 PM
To: nant-users@lists.sourceforge.net
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

 

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to