Search code examples
nant

nant directory::exists returns false even though directory exists


I'm trying to check for if a directory exists as part of a NAnt script and getting a false negative. Here is the script fragment:

<echo message="${backup.dir} --> ${directory::exists('${backup.dir}')}"/>

Here is the output:

[echo] D:\D\RTC\backup\20110223 --> False

Except the directory exists.

As a side note if I run..

<echo message="${backup.dir} --> ${directory::get-creation-time('${backup.dir}')}"/>

I get the following error:

Expression: ${backup.dir} --> ${directory::get-creation-time('${backup.dir}')}
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Could not find a part of the path "D:\D\RTC\${backup.dir}".

AND if I run..

<echo message="Directory Name --> ${path::get-directory-name('${backup.dir}')}"/>

I get

[echo] Directory Name -->

All in all I'm very confused right now.. Any thoughts?


Solution

  • You must not use ${} in a nested way:

    <echo message="${backup.dir} --> ${directory::exists(backup.dir)}"/>