Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get csc.exe path?

Tags:

c#

.net

csc

Is there a way to get path for the latest .NET Framework's csc.exe?

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.

Any solution to this?

like image 746
Rok Povsic Avatar asked Jul 12 '11 06:07

Rok Povsic


People also ask

How do I fix csc.exe error?

The most common fix for the csc.exe error is to uninstall the . NET Framework, then download the latest version of the framework, and reinstall it on your computer. On the download page, ensure that you download the recommended version at the top of the list. That's the most recent one.

How do I know if C# compiler is installed?

Open the Command Prompt window (search for cmd). 3. To check if the path of the C# compiler is set as Environment Variable, type csc and press Enter. You should get something as shown below.

How do I compile a .CS file?

Open the command prompt tool and go to the directory where you saved the file. Type csc helloworld. cs and press enter to compile your code. If there are no errors in your code, the command prompt takes you to the next line and generates helloworld.exe executable file.


2 Answers

c:\Windows\Microsoft.NET\Framework\vX.X.XXX Should contain the latest 32 bit version of csc.exe

c:\Windows\Microsoft.NET\Framework64\vX.X.XXX Should contain the lastest 64 bit version of csc.exe

That's what it is for mine anyway.

BTW: You can access both by using the Visual Studio Command Line from your visual studio tools folder in your program files. It auto sets up all the paths you need to build 32 and 64 bit apps with your csc compiler.

like image 75
Liquid Wotter Avatar answered Sep 23 '22 13:09

Liquid Wotter


The best way to find CSC.exe path is running in CLI (Command Line Interpreter) that simple line:

dir /s %WINDIR%\CSC.EXE 

dir - shows directory

/s - includes subfolders

%WINDIR%\CSC.EXE - looks in root folder for phrase like "CSC.exe".

And it is our result: enter image description here

Then we can simply compile example code by line like:

C:\WINDOWS\...\v.4.0.30319\CSC.exe HelloWorld.cs 

Regards.

like image 20
Bear Avatar answered Sep 21 '22 13:09

Bear