I don't think there is an else. But, I've found the following to be more
readable.
<target name="unitTest" description="runs nunit tests on the
project">
<call target="unitTestCustom"
if="${target::exists('unitTestCustom')}" />
<echo message="Standard NUnit processing ..." unless="
target::exists('unitTestCustom')"/>
</target>
Move your echos elsewhere. Or create a separate target which can have
echos and stuff in it.
BOb
________________________________
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Parrish,
Ken
Sent: Wednesday, January 23, 2008 4:57 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] New to list - How best to create
if-else-endifconstruct ...
I'm new to this list, so am not sure if this question has been posted
frequently or recently.
I'm often frustrated when I need to create an if-else-endif construct in
a Nant script. For example:
<target name="unitTest" description="runs nunit tests on the
project"> e
<if test="${target::exists('unitTestCustom')}" >
<echo message="Calling custom NUnit target ..." />
<call target="unitTestCustom" />
</if>
<if test="${not target::exists('unitTestCustom')}" >
<echo message="Standard NUnit processing ..." />
</if>
</target>
Seems really messy to me. The test is executed multiple times and is
prone to mistakes if the conditional is not corrected in both places.
In the case of a test that validates a potential failure, I've used:
<target name="unitTest" description="runs nunit tests on the
project"> e
<if test="${target::exists('dontDoThis')}" >
<echo message="Not something I want to do ..." />
<fail message="Bad target - exiting ..." />
</if>
<echo message="Standard NUnit processing..." />
</target>
Any ideas on a better way to create if-else-endif conditional blocks?
Thanks,
Ken
Gomez, Inc.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users