We're using Nant 0.91 so <choose> is not available. How would you do an IF/ELSE in Nant 0.91? I would like to do something like (using NAnt 0.92 syntax) in NAnt 0.91. [I am not allowed to modify the current installation of NAnt 0.91]:
<choose>
<when test="${deploy.env=='PROD'}">
<property name="deploy.root.dir" value="\\${deploy.server}\${deploy.mode}\${app.dest.dir}\" />
</when>
<otherwise>
<property name="deploy.root.dir" value="\\${deploy.server}\${deploy.mode}\${deploy.env}\${app.dest.dir}\" />
</otherwise>
</choose>
The simplest solution, which we use here, is to just use two if
tasks, one with a negative test to the other:
<if test="${deploy.env == 'PROD'}">
<property name="deploy.root.dir" value="\\${deploy.server}\${deploy.mode}\${app.dest.dir}\" />
</if>
<if test="${deploy.env != 'PROD'}">
<property name="deploy.root.dir" value="\\${deploy.server}\${deploy.mode}\${deploy.env}\${app.dest.dir}\" />
</if>
However in your case, you can also make use of the fact that the property
task has inbuilt if
/unless
functionality:
<property name="deploy.root.dir" if="${deploy.env == 'PROD'}" value="\\${deploy.server}\${deploy.mode}\${app.dest.dir}\" />
<property name="deploy.root.dir" unless="${deploy.env == 'PROD'}" value="\\${deploy.server}\${deploy.mode}\${deploy.env}\${app.dest.dir}\" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With