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

1
  • 1
    That's not the exact C++ command line, only the buildlog.htm has it. The C# one is in the Output window. Commented Apr 1, 2011 at 21:27

4 Answers 4

9

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

4 Comments

Does not make sense, why the debug output view will contain the compiler command line. The build output does not contain the command line.
It absolutely does my friend! Chose the "Show output from: Build" in the option.
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 ==========
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 ==========
2

See MSDN: Command-line Building With csc.exe

1 Comment

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.
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.

1 Comment

Very useful info. This should be the accepted answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.