2

I know that Visual studio internally uses a tool called msbuild to compile C# code. Does msbuild internally use csc.exe (that comes with the .net framework) for compiling code? Or does Visual studio come with its own compiler?

Update (A little deviation from the original question): Powershell uses .net types. So does powershell also target csc.exe? If yes, doesn't that mean that powershell is not pure scripting?

Foo
  • 4,206
  • 10
  • 39
  • 54
  • 3
    `msbuild` does not compile C# code. `msbuild` reads `.csproj` files and the likes to call the actual C# compiler, `csc`, with the proper arguments (options, files, etc). `csc` ships with the .NET framework. – user703016 Aug 24 '14 at 19:28
  • 1
    The relationship between MSBuild and the .NET Framework has [changed](http://blogs.msdn.com/b/visualstudio/archive/2013/07/24/msbuild-is-now-part-of-visual-studio.aspx). It is not longer packaged with the .NET Framework. It is part of the Build Tools that are installed with VS. Csc is also included with the build tools. – Mike Zboray Aug 24 '14 at 19:56

3 Answers3

7

MSBuild uses csc.exe as its actual compiler, it uses solution and project files to build the project.

And also note that csc comes as a part of the .Net framework.

When you build a project by using the Visual Studio IDE, you can display the csc command and its associated compiler options in the Output window. To display this information, follow the instructions in How to: View, Save, and Configure Build Log Files to change the verbosity level of the log data to Normal or Detailed. After you rebuild your project, search the Output window for csc to find the invocation of the C# compiler.

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • @leppie:- I got that point. But I thought that since MSBuild uses the csc.exe then we can say that but yes that is not technically correct. Thanks for that :) – Rahul Tripathi Aug 24 '14 at 19:43
4

The CoreCompile task defined in Microsoft.CSharp.targets uses the CSC task to perform the compilation.

Lee
  • 142,018
  • 20
  • 234
  • 287
0

MsBuild is essentially a build scheduling framework supplemental to compilers to manage all aspects of the build. Each supported language would have their own suite of MsBuild logic that dictates what occurs when the project is built. For C# projects, the compiler logic would be called from CSharp.Targets, while building a database project would entail using the targets file installed with that add on.

Nicodemeus
  • 4,005
  • 20
  • 23