Search code examples
nant

NAnt IF task doesn't seem to work


I'm trying the example from the NAnt documentation for the if task at:

http://nant.sourceforge.net/release/0.85/help/tasks/if.html

Specifically the following code...

<if test="${build.configuration='release'}">
    <echo>Build release configuration</echo>
</if>

where build.configuration has been defined beforehand as

<property name="build.configuration" value="debug" overwrite="false" />

When I run it using nant.exe (version 0.91.3881.0), I get the following error:

'}' expected
Expression: ${build.configuration='release'}
                                 ^

I'm guessing I'm missing something simple?


Solution

  • You need to double the = symbol as per your web page.

    When programming, = is an assignment operator in most languages, whereas == is the boolean comparison operator.