NAnt :: exists () property with new property definition?

In NAnt 0.92, I define a property immediately after its existence. He does not exist ... but he exists for the named purpose. Is this a bug or a function?!? I am looking in the documentation, but cannot find a mention of this.

<target name="test"> <property name="testprop" value="test value" /> <echo message="property value = ${testprop}" /> <if test="${property::exists(testprop)}"> <echo message="property exists, as it should!" /> </if> <if test="${not property::exists(testprop)}"> <echo message="property doesn't exists... WTF?" /> </if> <call target="test2" /> </target> <target name="test2"> <echo message="property value in sub-target = ${testprop}" /> </target> 

Output:

Test:

  [echo] property value = test value [echo] property doesn't exists... WTF? 

test2:

  [echo] property value in sub-target = test value 
+4
source share
1 answer

The property name must be specified in your call to property::exists . So here it is:

 <if test="${not property::exists('testprop')}"> <echo message="property doesn't exists... WTF?" /> <!-- don't swear --> </if> 

Update: What happens in your example? The testprop property testprop is replaced by the value in your function property::exists function call. So you are actually investigating the test value property (that BTW is not a valid property name). Check this:

 <target name="test"> <property name="test.value" value="foo" /> <property name="testprop" value="test.value" /> <echo message="property value = ${testprop}" /> <if test="${property::exists(testprop)}"> <echo message="property exists, as it should!" /> </if> <if test="${not property::exists(testprop)}"> <echo message="property doesn't exists... WTF?" /> </if> </target> 

Output:

  [echo] property value = test.value [echo] property exists, as it should! 
+5
source

All Articles