Hello,

 

I could use some advice about how to handle this situation:

 

I have a property, MyProperty, that may or may not be set.  I want a task to 
execute if the property is set, e.g.

<echo messsage="Hello ${MyProperty}!" if="${property::exists('MyProperty')" />

 

If MyProperty is not set, this task fails because NAnt appears to evaluate the 
message portion regardless of the result of the IF evaluation.  I could rewrite 
like this:

 

<if test="${property::exists('MyProperty')}">

    <echo message="Hello ${MyProperty}!" />

</if>

 

However, I run into the same issue with filterchains:

 

<!-- FAILS if MyProperty is not set, because NAnt evaluates the tokens 
regardless of the IF result -->

<copy failonerror="true" verbose="true" todir="C:\Temp">

    <fileset refid="Deploy-FileSet" />

    <filterchain>

        <replacetokens begintoken="[" endtoken="]" ignorecase="true" 
if="${property::exists('MyProperty')}">

            <token key="ABC" value="${MyProperty}" />

        </replacetokens>

    </filterchain>

</copy>

 

I'd rather not enclose the whole definition of the copy in an IF, with a nearly 
identical "else" version for the case when MyProperty is not set.

 

How have you handled this situation?

 

Thanks,

Durand
                                          
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to