MsBuild:获取目标的当前目录
我有一个 msbuild 目标,它有一个如下所示的导入标签:
<Import Project="$(MSBuildExtensionsPath)\Company\Company.LifeCycle.targets" />
在 Company.LifeCycle.targets 文件的内容中,如何以编程方式获取当前目录(在本例中为:C:\Program Files\MsBuild\Company ) ??
我使用 VS 2008,.NET 3.5
编辑:我已经看到了参考,如何获取 msbuild 脚本中的当前目录?,但对我无效:$(MSBuildProjectDirectory 给我这个值,C:\Work\Company\Projects\Test001\ProyectSW3
I have a msbuild target and it has a Import tag like this:
<Import Project="$(MSBuildExtensionsPath)\Company\Company.LifeCycle.targets" />
In contents of Company.LifeCycle.targets file, how can I get programatically the current directory (in this case is: C:\Program Files\MsBuild\Company) ??
I use VS 2008, .NET 3.5
Edit: I have seen the reference, How can I get current directory in msbuild script?, but not valid for me: $(MSBuildProjectDirectory give me this value, C:\Work\Company\Projects\Test001\ProyectSW3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 MSBuild 4,您可以使用新属性“MSBuildThisFileDirectory”,请参阅我的博客 http://sedodream。 com/2010/03/11/MSBuild40ReservedProperties.aspx。如果您没有使用 MSBuild 4,则无法轻松完成此操作。
With MSBuild 4 you can use the new property 'MSBuildThisFileDirectory' see my blog http://sedodream.com/2010/03/11/MSBuild40ReservedProperties.aspx. If you are not using MSBuild 4, you cannot do this easily.
您的问题已在另一篇文章中得到解答:MsBuild:获取目标的当前目录。我希望那里的答案能让您满意。
您几乎可以使用
MSBuildProjectDirectory
,它将为您提供当前项目文件的路径,您可以在此基础上进行构建。Your question has already been answered in another post here: MsBuild: Get current directory of targets. I hope the answers there satisfy you.
You can pretty much use
MSBuildProjectDirectory
which will give you the path to your current project file and you can build upon that.