Nant directory :: exists returns false, although the directory exists

I am trying to check if a directory exists as part of an NAnt script and gets a false negative. Here is the script fragment:

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

Here is the result:

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

Except that 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?

+3
source share
1 answer

You should not use in a ${}nested manner:

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

Source: https://habr.com/ru/post/1794244/


All Articles