Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Evaluating property equality in Nant

In my Nant script I would like to compare a property value to a known string. After reading the Nant Expressions documentation I believed I would be able to do a basic '==' comparison to evaluate as a boolean.

However given the script block:

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

When executed I recieve 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.

This seems as though it should be simple (and probably is). How do I compare two strings, or properties in Nant to evaluate as a boolean?

like image 538
berko Avatar asked Apr 30 '09 23:04

berko


3 Answers

It also works if you have the entire expression within the curly braces:

<if test="${target.env =='Dev'}">
    ....
</if>
like image 110
bentsai Avatar answered Oct 17 '22 20:10

bentsai


See here for example. e.g.

<if test="${target.env}=='Dev'">
    ....
</if>
like image 40
Preet Sangha Avatar answered Oct 17 '22 20:10

Preet Sangha


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

<if test="${test.var1 == test.var2}">
....
</if>
like image 44
Mathulan Avatar answered Oct 17 '22 19:10

Mathulan