nant - 如果南特的条件

标签 nant

我想弄清楚如何在 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} &amp;&amp; ${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/

相关文章:

windows - 使用 NAnt 在构建脚本中安装/卸载 Windows 服务

nant - 如何从 NANT 返回特定的退出代码?

msbuild - 使用 NAnt 代替 MSBuild 有什么好处?

continuous-integration - 自动构建失败时播放声音

visual-studio - 如何在NAnt中设置工作目录?

nant - 如何从另一个构建文件执行 nant 构建文件?

powershell - 在NAnt构建系统中使用PowerShell Cmdlet的好方法是什么?

cruisecontrol.net - 从 stylecop 检查中排除文件

NAnt property::exists() 具有新定义的属性?

nant - 使用Nant创建目录