If the condition is in nant

I am trying to figure out how to write a simple if condition in nant which will evaluate to true when the properties x and y are true.

<project default="all">
    <property name="x" value="True" />
    <property name="y" value="True" />
    <target name="all">
        <echo message="x is True" if="${x}" />
        <echo message="y is True" if="${x}" />
        <echo message="x AND y are True" if="${x} AND ${y}" />
        <echo message="x AND y are True" if="${x} &amp;&amp; ${y}" />
    </target>
</project>

I can not understand the syntax of the message x AND y echo - I tried both AND and '& &' and this does not seem to work (I continue to receive error messages like: String was not recognized as a valid boolean.)

+3
source share
1 answer

You want to use if = "$ {x and y}", where x and y are in the same pair of brackets:

<project default="all">
    <property name="x" value="true" />
    <property name="y" value="true" />
    <target name="all">
        <echo message="x is True" if="${x}" />
        <echo message="y is True" if="${y}" />
        <echo message="x AND y are True" if="${x and y}" />

    </target>
</project>

Hope this helps!

+5
source

Source: https://habr.com/ru/post/1727405/


All Articles