Skip to content

Enabling the binary logger adds console output #7828

@rolfbjarne

Description

@rolfbjarne

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:

msbuild/src/MSBuild/XMake.cs

Lines 3184 to 3187 in f25c1ee

// If we have a binary logger, force verbosity to diagnostic.
// The only place where verbosity is used downstream is to determine whether to log task inputs.
// Since we always want task inputs for a binary logger, set it to diagnostic.
verbosity = LoggerVerbosity.Diagnostic;

msbuild/src/MSBuild/XMake.cs

Lines 2344 to 2348 in f25c1ee

if (verbosity == LoggerVerbosity.Diagnostic)
{
string equivalentCommandLine = commandLineSwitches.GetEquivalentCommandLineExceptProjectFile();
Console.WriteLine($"{Path.Combine(s_exePath, s_exeName)} {equivalentCommandLine} {projectFile}");
}

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

Metadata

Metadata

Assignees

Labels

Good First IssueSelf-contained issues good for first-time contributors.bugtriaged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions