我想弄清楚如何在 nant 中编写一个简单的 if 条件 当 x 和 y 属性都为真时,它的计算结果为真。
<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} && ${y}" />
</target>
</project>
我无法弄清楚 x AND y 回显消息的语法 - 我尝试了 AND 和 '&&' 但这似乎不起作用。(我不断收到错误消息,例如:String was not recognized as a valid Boolean .)
最佳答案
你想使用 if="${x and y}",其中 x 和 y 在同一对括号中:
<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>
希望对您有所帮助!
关于nant - 如果南特的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2008607/