You need to include XYZ in single quotes because you want to pass the string to the property::exists method and not evaluate the XYZ property.

 

Try:

 

 <property if="${property::exists(‘XYZ’)}" name="IsItThere" value="yes"/>

Noel


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Frederick
Sent: Friday, July 21, 2006 2:00 PM
To: nant-users@lists.sourceforge.net
Subject: [NAnt-users] How do you detect if a property has not been defined?

 

Uh, I'm a little lost here.  Sorry, beginner question.

 

I want to detect if a property has/has not been defined and do conditional processing based on whether or not the property exists.  I thought I should do:

 

<project name="test">
 <property if="${property::exists(XYZ)}" name="IsItThere" value="yes"/>
</project>

 

And then I run it:

 

C:\build\BuildIt>nant -f:prop.build
NAnt 0.85 (Build 0.85.2344.0; rc4; 6/2/2006)
Copyright (C) 2001-2006 Gerry Shaw
http://nant.sourceforge.net

 

Buildfile: file:///C:/build/BuildIt/prop.build
Target framework: Microsoft .NET Framework 2.0

 


BUILD FAILED

 

C:\build\BuildIt\prop.build(2,3):
Property evaluation failed.
_expression_: ${property::exists(XYZ)}
                               ^^^
    Property 'XYZ' has not been set.

 

Total time: 0 seconds.

 

But that always complains that the property isn't defined.  Uh, that's what I wanted to detect...And no, using overwrite="false" is not what I need...this is a simplified example.  Anybody have any ideas?

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to