MSBuild 项目是否有任何方法可以确定正在运行的 MSBuild 版本是 32 位还是 64 位版本?

发布于 2024-09-16 13:34:43 字数 374 浏览 3 评论 0原文

找到我的问题的答案后关于 64 位版本的 MSBuild 尝试加载 32 位扩展,现在我有必要确定正在运行的是 64 位版本还是 32 位版本的 MSBuild,以便我可以加载正确版本的 DLL。

我可以根据已知路径列表检查 $(MSBuildBinPath) 变量,但如果 MSBuild 从某个非标准位置运行,则这将不起作用。这不是一个优雅的解决方案。

是否有某种方法可以可靠地确定当前运行的 MSBuild(或托管 MSBuild 引擎的其他进程)是 32 位还是 64 位?

After having found the answer to my question about the 64-bit version of MSBuild attempting to load 32-bit extensions, it has now become necessary for me to determine whether the 64-bit or 32-bit version of MSBuild is running so I can load the correct version of the DLL.

I can check the $(MSBuildBinPath) variable against a list of known paths, but that will not work if MSBuild is running from some non-standard location. This is not an elegant solution.

Is there some way to reliably determine whether the currently running MSBuild (or other process hosting the MSBuild engine) is 32-bit or 64-bit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

秋凉 2024-09-23 13:34:43

您是否考虑过编写一个返回当前进程的位数的自定义 MSBuild 任务?

请参阅如何使用 .NET 检测 Windows 64 位平台?< /a> 为例。

Have you considered writing a custom MSBuild task that returns bitness of the current process?

See How to detect Windows 64-bit platform with .NET? for an example.

彡翼 2024-09-23 13:34:43

有一个相关问题找出“位” MSBuild 中当前操作系统的状态。在该问题中,Blindy 给出了答案:


在 64 位操作系统上,定义了以下变量:

ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)

所以只是测试 ProgramFiles(x86),如果它为空,则使用 ProgramFiles

There is a related question at Find out the "Bit"ness of the current OS in MSBuild. In that question there is an answer by Blindy stating:


On a 64-bit OS, the following variables are defined:

ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)

So just test for ProgramFiles(x86) and if it's empty, use ProgramFiles.

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