如何获得csc.exe的路径? [英] How to get csc.exe path?
问题描述
有没有一种方法来获得路径最新的.NET Framework的csc.exe的?
Is there a way to get path for the latest .NET Framework's csc.exe?
通常的文件:C:\ WINDOWS \ Microsoft.NET \框架\ vX.X.XXX但问题是可以有多个版本的安装+有32位和64位版本
The file usually in: c:\Windows\Microsoft.NET\Framework\vX.X.XXX but the problem is there can be multiple versions installed + there are both 32 and 64 bit versions.
任何解决办法?
推荐答案
一个线索,以一个合理的答案是可以找到<一href="http://stackoverflow.com/questions/199080/how-to-detect-what-net-framework-versions-and-service-packs-are-installed">here.您可以在 HKEY_LOCAL_MACHINE \ SOFTWARE \微软\ NET Framework安装\新民主党
(为版本1.1及以后,我认为)枚举安装从注册表中的.NET Framework的版本。在每个键(或配置文件子项,在4.0的情况下),你会发现安装路径
这将指向框架的安装位置。你需要枚举在 NDP
所有子项和翻译每一个成一个版本号,然后找到最新的。为了检测在64位操作系统上运行的64位进程的32位版本,你需要在等同的位置看在 Wow6432Node
在注册表中。
One clue to a reasonable answer is to be found here. You can enumerate installed versions of the .NET Framework from the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
(for versions 1.1 and onwards, I think). Under each key (or profile subkey, in the case of 4.0), you'll find InstallPath
which will point to the installation location of the framework. You'll need to enumerate all subkeys under NDP
and translate each one into a version number and then find the latest. To detect 32-bit versions running in a 64-bit process on a 64-bit OS, you'll need to look under the equivalent locations under Wow6432Node
in the registry.
这一切都有点难看,但可能是唯一可靠的方法来做到这一点。
It's all a bit ugly, but is possibly the only reliable way to do it.
这篇关于如何获得csc.exe的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!