NAnt - 如何获取包含脚本的目录路径 [英] NAnt - how to get the directory path of the included script

查看:133
本文介绍了NAnt - 如何获取包含脚本的目录路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个常见的NAnt脚本(包含一些常见的目标和常量),它包含在许多其他的NAnt脚本中,如下所示:

I have a common NAnt script (containing some common targets and constants) that I include in many other NAnt scripts like this:

<include buildfile="<path>\common.build" verbose="true" />

调用脚本位于各种文件夹中。

Calling scripts are in various folders.

在这个包含的脚本中,我需要从同一目录中读取包含脚本所在的文件。
当前目录设置为调用脚本的目录,不包括一个。
如何获取包含的脚本的目录路径?

In this included script I need to read a file from the same directory, where included script resides. "Current directory" is set to the directory of the calling script, not included one. How can I get the directory path of the included script?

如果我使用以下构造(包含脚本内):

If I use the following construct (inside included script):

${ path::get-directory-name(project::get-buildfile-path()) }

然后我得到调用脚本的文件夹路径,而不是包含的脚本。

then I get the folder path of the calling script, rather than of the included script.

有没有什么办法可以获得包含的脚本的路径?

Is there any way to get the path of the included script inside it?

问候,
Ivan。

Regards, Ivan.

推荐答案

我的建议:在调用脚本中的一个属性中定义被调用脚本文件的路径,如下所示:

My suggestion: Define the path to the called script file in a property inside the calling script like this:

<property name="include.buildfile.path" value="C:\foo\common.build" />
<include buildfile="${include.buildfile.path}" verbose="true" />

我访问所需目录路径的常用脚本如下:

I the common script you access the desired directory path like this:

${path::get-directory-name(include.buildfile.path)}

这篇关于NAnt - 如何获取包含脚本的目录路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆