Bugs item #940942, was opened at 2004-04-23 21:45
Message generated for change (Comment added) made by drieseng
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=940942&group_id=31650

Category: Documentation
Group: 0.8.4.0
Status: Open
Resolution: None
Priority: 5
Submitted By: Kevin Sagon (ksagon)
Assigned to: Gert Driesen (drieseng)
Summary: if & unless attribute of target tag

Initial Comment:
The if and unless attributes of the target tag are 
documented and are intended to function on the 
premise that they will "sense" the existence or non-
existence of the property specified by their value.  
Unfortunately it looks as if they are coded so that if the 
property exists then an attempt is made to convert the 
value to a boolean and return that result.  If I am 
reading the code right the value that is used for 
conversion is the value of the property specified, this 
will usually result in a conversion error as the value of 
the property was not intended to be used in this way.  
Indeed, the presence of the property is all that should 
be checked for to stay consistent with both the 
documentation and the Java version of the same 
functionality.

The code in question is in the Target.cs source lines 
108-117 (if attribute) and lines 148-157 (unless 
attribute).

If you would like more details please feel free to contact 
me.

----------------------------------------------------------------------

>Comment By: Gert Driesen (drieseng)
Date: 2004-07-20 12:05

Message:
Logged In: YES 
user_id=707851

You need a NAnt 0.85 nightly build 
(http://nant.sourceforge.net/nighlty/builds) in order to have 
expression support.

----------------------------------------------------------------------

Comment By: MArcin Slusarczyk (mslusar)
Date: 2004-07-20 11:55

Message:
Logged In: YES 
user_id=799500

Example presented by drieseng :
<target name="dunno" if="${file::exists('test.txt')}">
    ....
</target>
Does not work for me. I got error:
Property 'file::exists('build.xml')' has not been set.

----------------------------------------------------------------------

Comment By: explorer (junp50)
Date: 2004-06-29 19:39

Message:
Logged In: YES 
user_id=1073549

I followed the instructions posted by drieseng, but I still
got errors

INTERNAL ERROR

System.FormatException: String was not recognized as a valid
Boolean.
   at System.Boolean.Parse(String value)
   at System.Convert.ToBoolean(String value)
   at NAnt.Core.Tasks.IfTask.get_ConditionsTrue() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmpsrc\NAnt.Core\Tasks\IfTask.cs:line 271
   at NAnt.Core.Tasks.IfTask.ExecuteTask() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmp\src\NAn
t.Core\Tasks\IfTask.cs:line 333
   at NAnt.Core.Task.Execute() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmp\src\NAnt.Core\Task.
cs:line 176
   at NAnt.Core.Target.Execute() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmp\src\NAnt.Core\Tar
get.cs:line 249
   at NAnt.Core.Project.Execute(String targetName, Boolean
forceDependencies) in C:\DOCUME~1\driesen
g\LOCALS~1\Temp\tmp15EB.tmp\src\NAnt.Core\Project.cs:line 870
   at NAnt.Core.Project.Execute() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmp\src\NAnt.Core\Pr
oject.cs:line 827
   at NAnt.Core.Project.Run() in
C:\DOCUME~1\drieseng\LOCALS~1\Temp\tmp15EB.tmp\src\NAnt.Core\Projec
t.cs:line 895

Please send bug report to [EMAIL PROTECTED]

----------------------------------------------------------------------

Comment By: Gert Driesen (drieseng)
Date: 2004-05-02 10:04

Message:
Logged In: YES 
user_id=707851

Kevin,

This is actually a documentation issue.  The NAnt developers 
took a departure from their Ant counterpart on this topic, and 
forgot to update the docs accordingly.  

In NAnt the if and unless attributes expect an expression that 
evaluates to either true or false.

To be honest : when I first started working on NAnt I didn't 
agree with this departure from Ant's logic too, but that 
departure does allow us to have expressions in the if and 
unless attributes now, without breaking any existing builds.

Right now, you could have a target executed only if a certain 
file exists, without having to use intermediate properties to 
hold a bool indicating whether the file exists or not :

<target name="dunno" if="${file::exists('test.txt')}">
    ....
</target>

I'm updating the category of this bug report 
to "Documentation", and wil fix the docs in the next few 
days ...

Thanks for the report !

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=402868&aid=940942&group_id=31650


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to