74

I want to do a build from the command line, but I'd like to get the exact command line syntax from Visual Studio (2012), so that I don't have to manually figure out all of the flags, imports, and other parameters.

Is there a way to get Visual Studio to display this information?

4
  • Doesn't it show up in the Output window?
    – acfrancis
    Nov 6, 2013 at 20:54
  • 1
    The build output does, warnings, errors, etc., but not the full command line used. Unless I'm missing something... Nov 7, 2013 at 0:25
  • 2
    It does but only with the right configuration. See this question: stackoverflow.com/questions/9016111/…
    – acfrancis
    Nov 7, 2013 at 11:13
  • Ah, that worked! If you post that link as an answer (ideally pasting the relevant part of the answer), I'll accept it as the answer to this question. Thanks! Nov 7, 2013 at 20:35

3 Answers 3

69

When you build a project or solution in Visual Studio, the entire command line used to run the compiler (csc.exe, including switches and parameters) is displayed in the Output window. If you don't see it there, check the Verbosity level by going to:

Options > Projects and Solutions > Build and Run > MSBuild project build output verbosity

(You may need to choose "Show all settings") options in toolbar -- finding projects and solution in options

It has to be set to "Normal" or higher. Check this question and answer for more details:

To see all command line on output window while compiling

3
  • 11
    Sorry, guys, but I'm working with Visual Studio 2017 and I don't see the "Show all settings" checkbox, and obviously I don't see the command, even while having "Detailed" or "Diagnostic" verbosity. Any ideas?
    – Dominique
    Jul 7, 2017 at 7:54
  • 3
    @Dominique, The show all is not there, but the two options on the right are there. Oct 31, 2017 at 13:46
  • 1
    This answer is invalid for Visual Studio 2017 or higher @Dominique is correct. These suggestions don't work. Jan 30 at 13:44
18

I don't have enough reputation to comment acfrancis's answer, so I just post this simple answer: In Visual Studio 2017, following acfrancis's answer, but set two option to Detailed: enter image description here and then copy the output, search cl.exe and link.exe(Well a lot of lines, In this case 730 lines, I can't fint both without search), you can find something like this: enter image description here enter image description here

1

The output window on verbose mode produces a lot of text. If you are interested in compilation and linking flags there is an easier way.

Just check your project configuration properties, C/C++ -> Command Line and Linker -> Command Line

enter image description here

1
  • 1
    Unfortunately that doesn't show all the options used, such as <AdditionalOptions>...</AdditionalOptions> that may be specified in .props files within the solution, whereas the technique above of getting detailed MSBuild information will include such options
    – Tim
    Sep 20, 2022 at 15:26

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.