If I remember correctly, the whole line will be evaluated, so you will get
an error, because the message is evaluated, but not executed if the if
attribute is false.  I think what you need for this scenario is:

<if test="${property::exists('property2'}">
        <echo message="property2 is ${property2}" />
</if>

Cheers,

Bill


 -----Original Message-----
From:   T.G. Mutato [mailto:[EMAIL PROTECTED] 
Sent:   17 February 2005 02:00
To:     nant-users@lists.sourceforge.net
Subject:        [Nant-users] Problem with property evaluation

 << File: TestProperties.build >> Check out this code fragment:

<target name="nowork" description="this one does not work when
property is not set">
   <echo message="property2 is ${property2}"
if="${property::exists('property2')}" />
</target>

The echo statement shouldn't happen if property2 doesn't exist;
however, the following error happens:

Property evaluation failed.
Expression: property2 is ${property2}
                           ^^^^^^^^^
    Property 'property2' has not been set.

Should this be reported as a bug somewhere?

I've attached a short build file which demonstrates the issue.




UK businesses use 2 million tonnes of paper each year.
THINK before you PRINT this email.
______________________________________________________________

CONFIDENTIALITY NOTICE

This communication and the information it contains is intended for the person 
or organisation to 
whom it is addressed.  Its contents are confidential and may be protected in 
law.  Unauthorised use,
 copying or disclosure of any of it may be unlawful.  If you are not the 
intended recipient, please 
contact us immediately.

The contents of any attachments in this e-mail may contain software viruses, 
which could damage your 
own computer system.  While Marlborough Stirling has taken every reasonable 
precaution to minimise 
this risk, we cannot accept liability for any damage, which you sustain as a 
result of software 
viruses.  You should carry out your own virus checking procedure before opening 
any attachment.

Marlborough Stirling plc, Registered in England and Wales 
Registered No. 3008820,
Jessop House, Jessop Avenue, Cheltenham, Gloucestershire, GL50 3SH
Tel: 01242 547000     Fax: 01242 547100
http://www.marlborough-stirling.com



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Nant-users mailing list
Nant-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to