MSBuild 项目是否有任何方法可以确定正在运行的 MSBuild 版本是 32 位还是 64 位版本?
找到我的问题的答案后关于 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否考虑过编写一个返回当前进程的位数的自定义 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.
有一个相关问题找出“位” MSBuild 中当前操作系统的状态。在该问题中,Blindy 给出了答案:
在 64 位操作系统上,定义了以下变量:
所以只是测试
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:
So just test for
ProgramFiles(x86)
and if it's empty, useProgramFiles
.