Karthikeyan
Karthikeyan

Reputation: 373

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?

Upvotes: 5

Views: 3279

Answers (2)

Tom Blodget
Tom Blodget

Reputation: 20772

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.

Upvotes: 4

Filburt
Filburt

Reputation: 18061

The call to csc.exe is contained in the according .targets1 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

Upvotes: 3

Related Questions