开发者

if condition in nant

开发者 https://www.devze.com 2022-12-15 07:56 出处:网络
I am trying to figure out how to write a simple if condition in nant that will evaluate to true when both x & y properties are true.

I am trying to figure out how to write a simple if condition in nant that will evaluate to true when both x & y properties 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 cannot figure out the syntax for the x AND y echo message - I tried both AND and '&&' and that doesn't seem to work.(i keep getting error messages like : String was not recognized as a valid Boolean.)


You want to use if="${x and y}", where both 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 that helps!

0

精彩评论

暂无评论...
验证码 换一张
取 消