【问题标题】:How to check in NAnt script whether property is set or not?如何检查 NAnt 脚本是否设置了属性?
【发布时间】:2011-11-03 13:18:54
【问题描述】:
您好,我正在使用 NAnt 创建一个发布脚本。如何检查变量值是否正在获取。
现在我这样调用我的脚本
nant -buildfile:CreateNew.build -D:name="Test.V.1.0" -D:bIDs="2" -D:uIDs="'3'"
有时我不会传递 uID。
所以我需要在我的 nant 脚本中检查 uID 是否正在获取。我该怎么做?
【问题讨论】:
标签:
xml
release
nant
nantcontrib
【解决方案1】:
您应该使用 property::exists 函数:
<if test="${property::exists('uIDs')}">
<echo message="uIDs is set" />
</if>
【解决方案2】:
大多数(甚至所有?)NAnt 任务都有 if/unless 属性。您可以将 property::exists() 函数与这些属性结合使用来调节构建脚本。