1

I'm trying to build a Visual Studio project, using Visual Studio 2017. This fails and the error list shows quite some Chinese characters.

I've understood that those characters are caused by a misinterpretation of the MSBuild command, so I've decided to run the MSBuild command myself, in order to see which error messages lead to the Chinese characters and in order to solve my problem.

Therefore, as mentioned in "this relevant StackOverflow post", I've modified my Visual Studio "MSBuild project build output verbosity" to "Detailed" (I even put it on "Diagnostic"), but although there was quite some information, I could not retrieve the MSBuild commandline from that output. As I mentioned in a comment, I don't have the checkbox "Show all settings" in my options window.

So I've tried doing something else: I opened a Command prompt and I went to the location of my Visual Studio project, and there I simply launched the command "\MSBuild.exe". This however was not a good idea: the project was building successfully and the number of warnings (864) did not correspond to the expected number of warnings, as seen in the error list of Visual Studio (3), so I'm left with two questions:

  1. I have different MSBuild.exe files on my PC, how can I know which one Visual Studio is using? (For your information, when I simply launch "MSBuild" it's not running: no MSBuild runtime directory in my $PATH environment variable)
  2. I believe some parameters might be used while launching a build using Visual Studio, how can I retrieve those from the output window?

In the meanwhile I've found out there is a tool, called "Developer command prompt". I've opened this tool, went to my project's directory and started up MSBuild. The build was successful, there are zero errors and zero warnings, so also this does not give an expected results.

Thanks in advance

Dominique
  • 16,450
  • 15
  • 56
  • 112

1 Answers1

1

1.I have different MSBuild.exe files on my PC, how can I know which one Visual Studio is using? (For your information, when I simply launch "MSBuild" it's not running: no MSBuild runtime directory in my $PATH environment variable)

You can right click you project, select "Unload Project", then right click and select the "Edit xx.csproj". In the top of the project file, you will notice that the statement for Toolversion:

<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

Besides, you can use "Ctrl+F" to search keywords "MSBuild" in the output windows("MSBuild project build output verbosity" to "Detailed"), you will find much more entries are MSBuild\15.0.

So we could to know the MSBuild.exe 15.0 (Locate at C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin ) is used by Visual Studio 2017.

2.I believe some parameters might be used while launching a build using Visual Studio, how can I retrieve those from the output window?

Yes, there are some parameters be used while launching a build using Visual Studio, for example, the Configuration: Dubug/Release; the proprieties: Target Framework. You can retrieve those parameters in the output windows by using "Ctrl+F" to search the search keywords.

How to retrieve the commandline, used while building a Visual Studio project I could not retrieve the MSBuild commandline from that output.

Just as you mentioned, I also could not find the checkbox "Show all settings" in options window. But this does not affect us to retrieve the command line from the output. You should change "MSBuild project build output verbosity" to "Detailed", then build the project, you will find the commandline in the output windows, for example(C# project):

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE ...

This latter command is the real issue here: the command which is run is not MSBuild.exe <something>, but csc.exe <something> (C# project) or CL.exe <something> (C/C++ project).

In order to make this work, the compilation command must be run from the directory C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE, and while launching the compilation command, one should not forget the double-quotes in order to handle the spaces in the directory names.

Dominique
  • 16,450
  • 15
  • 56
  • 112
Leo Liu
  • 71,098
  • 10
  • 114
  • 135