使用MSBuild 4.0,是否可以“简化”包含路径的属性?
假设我有一个包含的属性
c:\workdir\project\wonder\subproj\..\..\common
,并且我想将其减少/简化为
c:\workdir\project\common
此外,我还希望能够从当前目录或指定目录获取相对路径。
使用相同的起始属性并将当前工作目录设置为
c:\workdir\project\wonder
我希望它减少为
..\common
Suppose that I have a property containing
c:\workdir\project\wonder\subproj\..\..\common
and I want to reduce/simplify it to
c:\workdir\project\common
Furthermore, I would also like to be able to get a relative path from the current directory or specified.
Using the same starting property and having the current working directory set to
c:\workdir\project\wonder
I want it reduced to
..\common
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第一部分(解析路径中的“..”)相对简单,您只需使用 属性函数:
输出:
第二部分 - 相对于另一条路径缩短一条路径 - 需要使用一个神奇的函数
Uri.MakeRelativeUri()
和将其包装在内联任务(或外部任务库)内。声明你的任务:然后按如下方式使用它:
输出:
The first part (resolving '..' in path) is relatively simple, you can do this using just property functions:
Output:
The second part - shortening one path relatively to another - requires the use of a magical function
Uri.MakeRelativeUri()
and wrapping it inside an inline task (or an external task library). Declare your task:Then use it as follows:
Output: