MsBuild:获取目标的当前目录

发布于 2024-09-25 19:30:40 字数 530 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

轻许诺言 2024-10-02 19:30:40

对于 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.

转身以后 2024-10-02 19:30:40

您的问题已在另一篇文章中得到解答: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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文