开发者

"Proper" way to find path to C# compiler? [duplicate]

开发者 https://www.devze.com 2023-04-01 20:40 出处:网络
This question already has answers here: Closed 11 years ago. Possible Dupl开发者_Go百科icate: C# - How to get csc.exe path?
This question already has answers here: Closed 11 years ago.

Possible Dupl开发者_Go百科icate:

C# - How to get csc.exe path?

Is there a "proper" way to find the path to the C# compiler on a given system?

E.g. for Java, the "proper" way is to use the HKLM\Software\JavaSoft registry key to go through all the different JDKs and their locations, rather than assuming that everything is in %ProgramFiles%\Java.

Is there a similar method for C#?


You can find a list installed frameworks in: HKLM\Software\Microsoft.NetFramework

And on File system %Windows%\Microsoft.NET\Framework

Remembering only, you can access compiler services through the .net classes themselves.


I prefer something less system dependent:

string cscPath = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(typeof(object).Assembly.Location),"csc.exe");
0

精彩评论

暂无评论...
验证码 换一张
取 消