在 msbuild 中使用路径
我正在尝试使用 msbuild 和 msbuild 社区任务设置虚拟目录,但找不到指定 $(MSBuildStartupDirectory)
之外的相对路径的方法。
我的项目结构如下:
c:\proj\ src\ website (this is where the virtual dir should point to) build\ build.proj (this is the msbuild file)
我想做的是这样的(请注意 $(MSBuildStartupDirectory)
指向 c:\proj\build
):
<WebDirectoryCreate
VirtualDirectoryName="website"
VirtualDirectoryPhysicalPath="$(MSBuildStartupDirectory)\..\src\website" />
不幸的是这不起作用 - '..' 未解析,并且虚拟目录指向 c:\proj\build\..\src\website
。
谁能告诉我如何在 msbuild 中使用(相对)路径?
I'm trying to setup a virtual directory using msbuild and the msbuild community tasks but cannot find a way how to specify a relative path which is outside the $(MSBuildStartupDirectory)
.
My project is structured like this:
c:\proj\ src\ website (this is where the virtual dir should point to) build\ build.proj (this is the msbuild file)
What I'd like to do is something like this (note that $(MSBuildStartupDirectory)
points to c:\proj\build
):
<WebDirectoryCreate
VirtualDirectoryName="website"
VirtualDirectoryPhysicalPath="$(MSBuildStartupDirectory)\..\src\website" />
Unfortunately this doesn't work - the '..' is not resolved and and the virtual dir then points to c:\proj\build\..\src\website
.
Can anyone point me a hint how to work with (relative) paths in msbuild?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试过,它对我来说效果很好。我使用 msbuild 4.0 和社区任务版本 1.3.0.504 在 Windows XP 上对此进行了测试。
我通常使用 MSBuildProjectDirectory,因为 MSBuildStartupDirectory 可能指向其他地方,具体取决于 msbuild 的执行方式。
下面的示例将创建网站并使用 FullPath 元数据从路径中删除 .. 条目。
I tried that and it worked fine for me. I tested this on Windows XP using msbuild 4.0 and community tasks version 1.3.0.504.
I usually use MSBuildProjectDirectory since MSBuildStartupDirectory could be pointing elsewhere depending on how msbuild got executed.
The example below will create the web site and remove the .. entries from the path by using the FullPath metadata.