Equity Assessment in Nantes

In my Nant script, I would like to compare the value of a property with a known string. After reading the Nant Expressions documentation, I figured I could make a basic comparison of "==" to evaluate as logical.

However, given the script block:

<if test="${target.env} == Dev"> <echo message="***** You are using DEV"/> </if> 

When I execute, I get the following error:

 'Dev == Dev' is not a valid value for attribute 'test' of <if ... />. Cannot resolve 'Dev == Dev' to boolean value. String was not recognized as a valid Boolean. 

It seems like it should be simple (and probably have). How to compare two strings or properties in Nant to evaluate as logical?

+6
build-process nant
source share
3 answers

See here . eg.

 <if test="${target.env}=='Dev'"> .... </if> 
+9
source share

It also works if you have the whole expression in braces:

 <if test="${target.env =='Dev'}"> .... </if> 
+16
source share

if you want to compare two variables $ {test.var1} and $ {test.var2} then

 <if test="${test.var1 == test.var2}"> .... </if> 
+4
source share

All Articles