5

Visual Studio shows the exact command line use to compiler and link a C++ project under Project Properties -> C/C++ -> Command Line and Linker ->Command Line, but, I was not able to find similar property page for C# projects.

Does any know what's the best way to find out the csc.exe command line arguments used to compile a C# project

Faisal Mansoor
  • 2,041
  • 1
  • 21
  • 25

4 Answers4

8

Instead of using csc.exe directly, I would recommend looking at msbuild instead. With msbuild, you just have to run msbuild yourProject.csproj to compile it.

Also, per this MSDN blog, the csc.exe command line you see in the output window isn't really being used.

David
  • 34,223
  • 3
  • 62
  • 80
4

In Visual Studio, go to Debug->Windows->Output. When you compile your project this window will show you the commands it is using to compile your code, including the CSC command(s).

Be sure chose the "Show output from: Build" in the option dropdown in the Output window.

Mike Atlas
  • 8,193
  • 4
  • 46
  • 62
  • Does not make sense, why the debug output view will contain the compiler command line. The build output does not contain the command line. – Faisal Mansoor Apr 01 '11 at 20:37
  • It absolutely does my friend! Chose the "Show output from: Build" in the option. – Mike Atlas Apr 01 '11 at 20:45
  • Hmm you might be right, but, this is the output of build window for my test project. Do I need to enable some flag in Build config somewhere? ------ Rebuild All started: Project: Tests, Configuration: Debug x86 ------ Tests -> c:\users\admin\documents\visual studio 2010\Projects\Tests\Tests\bin\Debug\Tests.exe ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== – Faisal Mansoor Apr 01 '11 at 20:55
  • Hmm I'm using VS2008, not 2010. I guess it's different. You should use @David's answer, then. Here's my sample output: ------ Rebuild All started: Project: Blah, Configuration: Debug Any CPU ------ c:\WINDOWS\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport: {etc etc} Compile complete -- 0 errors, 0 warnings Blah -> E:\Blah\bin\Debug\Blah.exe ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== – Mike Atlas Apr 01 '11 at 21:00
2

See MSDN: Command-line Building With csc.exe

Mike Atlas
  • 8,193
  • 4
  • 46
  • 62
toby
  • 885
  • 3
  • 10
  • 21
  • Already did that, need to debug some weird problem where I am able to compile a C# file through IDE, but, while compiling it from command line I get an invalid executable. In anycase, I think it would be good to have access to exact command line that's used to build a project. Thanks anyways. – Faisal Mansoor Apr 01 '11 at 20:30
2

In Visual Studio 2010 go to

Tools->Options->Project and Solutions->Build and Run

change "MSBuild project build output verbosity" to something less filtering than Minimal (for example "Normal"). There will be a lot more talk in the Build Output window after this and you should be able to see the actual command line of how CSC was invoked.

Andersson
  • 111
  • 4