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

Reply via email to