msbuild
msbuild copied to clipboard
Enabling the binary logger adds console output
Issue Description
Requesting a binary log (/bl) will print a line to the terminal which isn't printed otherwise (when doing quiet builds).
Steps to Reproduce
$ msbuild test.csproj /bl /verbosity:quiet /nologo
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/15.0/bin/MSBuild.dll /nologo /bl /verbosity:quiet test.csproj
Expected Behavior
Quiet builds should be quiet:
$ msbuild test.csproj /verbosity:quiet /nologo
[no output]
Actual Behavior
An additional line of text (seems like the parsed MSBuild command line) is printed.
Analysis
I think the following two code blocks work together to cause this:
https://github.com/dotnet/msbuild/blob/f25c1ee15e92d7d71074df0dc6ab89ed40442545/src/MSBuild/XMake.cs#L3184-L3187
https://github.com/dotnet/msbuild/blob/f25c1ee15e92d7d71074df0dc6ab89ed40442545/src/MSBuild/XMake.cs#L2344-L2348
The extra line of text is also printed when not enabling the binary logger, but using diagnostic verbosity (but none of the other verbosity levels).
Versions & Configurations
$ msbuild --version
Microsoft (R) Build Engine version 16.10.1 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.
16.10.1.31401%
This also happens with dotnet build, so here's that version too:
$ dotnet --version
6.0.301
This sounds fairly straightforward to me. It would be good to check if we can just delay setting the verbosity to diagnostic; if not, we can store the "real" verbosity then use that for that check instead.
Hello there, would you assign this issue to me? I'd like to take this as my first commit to MSBuild. I tried the solution that uses another variable to store the original verbosity and check if the original verbosity equals quiet when binary logger is specified. It worked well on my local machine.
I prefer this solution because it makes the setting-the-verbosity-to-diagnostic independent of the verbosity value, though it introduces a new parameter to functions, it should be trivial for private function.
@fanhaipeng done! Please let us know if you have any questions. We look forward to the PR.
@rainersigwald would you help review the change? thanks