Search code examples
c#visual-studiocompilationmsbuildcsc

How MSBUILD calls CSC.exe?


I want to know about how msbuild.exe execute a C# application.

As i searched in google i came to know csc.exe,PE File, JIT, IL File. And msbuild.exe internally calls csc.exe to compile a C# Application. So I opened csc.exe in reflector. But There is no call csc.exe from msbuild. So how does msbuild call csc.exe?


Solution

  • Although, EXEs are indeed libraries (like DLLs, EXEs are PE files), they are almost always called by creating a separate process with command-line arguments. Command-line arguments are passed to the "main" function of the EXE, usually as an array of strings. You could find csc's main function with Reflector.

    But, you probably want to know what msbuild passes to csc for a particular build. In that case, just use msbuild's verbosity switch:

    msbuild MyProject.csproj /target:rebuild /verbosity:diag
    

    See Obtaining Build Logs with MSBuild.