开发者

Check if a target exists dynamically using Nant?

According开发者_运维知识库 to the Nant documentation, you can check if a target exists using the target::exists function.

Execute target "clean", if it exists.

<if test="${target::exists('clean')}">
<call target="clean" />
</if>

I've tried passing in the name of the target as a property and it doesn't seem to work.

Nant doesn't throw an error, but neither does it return true, when it should.

Essentially what I'm trying to do is this:

<property name="cleanTarget" value="${someothervariables}"/>

<if test="${target::exists('${cleanTarget}')}">
<call target="${cleanTarget}" />
</if>

Is it possible?


I worked it out, my syntax was wrong.

The correct way would be:

<property name="cleanTarget" value="${someothervariables}"/>

<if test="${target::exists(cleanTarget)}">
<call target="${cleanTarget}" />
</if>


You could simplify it to:

<property name="cleanTarget" value="${someothervariables}"/>

<call target="${cleanTarget}" if="${target::exists(cleanTarget)}" />
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜