Search code examples
c#visual-studiovisual-c++csccl

csc compiler for C# code


I am using Visual studio 2015. I think it uses the cl.exe compiler which is inside the Microsoft Visual Studio 14.0\VC\bin folder to compile C++ code. Also, my understanding is that the compiler used to compile C# code is csc.exe. However, I could not find this csc.exe inside my visual studio like cl.exe. I am curious to know how visual studio compiles C# code then. I think Visual Studio uses the csc.exe which comes with .Net, generally installed in C:\Windows\Microsoft.NET\Framework\\csc.exe to compile C# code. Is my understanding correct ?


Solution

  • I cannot answer why Roslyn is not present in your VS 2015 install dir. But you can examine how Visual Studio runs the csc.exe in the output window.

    Go to Tools->Options->Projects and Solutions->Build and Run, and select the build output verbosity. (you can select the most verbose option)

    enter image description here

    Then build your program. You can then check the command line used by MSBuild in the output window.

    Something like, ooh, I am using VS 2017...

    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /platform:anycpu32bitpreferred ... (a bunch of switches omitted)