简体   繁体   中英

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?

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 .

The call to csc.exe is contained in the according .targets 1 script.
MSBuild.exe itself is oblivious to which language compiler (c#, vb, ...) you are targeting. This is determined by the solution/project and their references.

The actual call to csc.exe should be located in Microsoft.MSBuild.Tasks.dll in your .NET Framework folder.

1 In case of C# it's Microsoft.CSharp.targets

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM