I don't think one can set conditions in any task as the script and output
below seems to demonstrate.  Even though the "setcondition" task sets the
"condition" property to false, the "doit" task still executes.  That being
the case it appears that one cannot really do conditional tasks by
dynamically setting a property.

Anyone have an alternate approach?

C:\My Documents>type condtest.build
<?xml version="1.0"?>
<project name="condtest" basedir=".">

    <!-- initialize condition -->
    <property name="condition" value="true"/>

    <target name="setcondition">
        <!-- some tasks here -->
        <property name="condition" value="false"/>
    </target>

    <target name="onlyifcondition" if="${condition}">
        <echo message="condition is true"/>
    </target>

    <target name="doit" depends="setcondition, onlyifcondition">
    </target>

</project>
C:\My Documents>nant -buildfile:condtest.build doit
NAnt version 0.8.3 Copyright (C) 2001-2003 Gerry Shaw
http://nant.sourceforge.net

Buildfile: file:///C:/My Documents/VWCypressWeb/cpw4/condtest.build

setcondition:


onlyifcondition:

     [echo] condition is true

doit:

Total time: 0 seconds.

BUILD SUCCEEDED


-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to