Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not print-out version info in terminal logger #9831

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2455,20 +2455,8 @@ private static bool ProcessCommandLineSwitches(
}
#endif

bool shouldShowLogo = !commandLineSwitches[CommandLineSwitches.ParameterlessSwitch.NoLogo] &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.Preprocess) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetProperty) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetItem) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetTargetResult) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.FeatureAvailability);

// show copyright message if nologo switch is not set
// NOTE: we heed the nologo switch even if there are switch errors
if (!recursing && shouldShowLogo)
{
DisplayVersionMessage();
}

bool useTerminalLogger = ProcessTerminalLoggerConfiguration(commandLineSwitches, out string aggregatedTerminalLoggerParameters);
DisplayVersionMessageIfNeeded(recursing, useTerminalLogger, commandLineSwitches);

// Idle priority would prevent the build from proceeding as the user does normal actions.
// This switch is processed early to capture both the command line case (main node should
Expand Down Expand Up @@ -2658,8 +2646,6 @@ private static bool ProcessCommandLineSwitches(

outputResultsCache = ProcessOutputResultsCache(commandLineSwitches);

bool useTerminalLogger = ProcessTerminalLoggerConfiguration(commandLineSwitches, out string aggregatedTerminalLoggerParameters);

// figure out which loggers are going to listen to build events
string[][] groupedFileLoggerParameters = commandLineSwitches.GetFileLoggerParameters();

Expand Down Expand Up @@ -4465,9 +4451,28 @@ private static void ThrowInvalidToolsVersionInitializationException(IEnumerable<
/// <summary>
/// Displays the application version message/logo.
/// </summary>
private static void DisplayVersionMessage()
private static void DisplayVersionMessageIfNeeded(bool recursing, bool useTerminalLogger, CommandLineSwitches commandLineSwitches)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));
if (recursing)
{
return;
}

// Show the versioning information if the user has not disabled it or msbuild is not running in a mode
// where it is not appropriate to show the versioning information (information querying mode that can be plugged into CLI scripts,
// terminal logger mode, where we want to display only the most relevant info, while output is not meant for investigation).
bool shouldShowLogo = !commandLineSwitches[CommandLineSwitches.ParameterlessSwitch.NoLogo] &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.Preprocess) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetProperty) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetItem) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.GetTargetResult) &&
!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.FeatureAvailability) &&
!useTerminalLogger;

if (shouldShowLogo)
{
Console.WriteLine(ResourceUtilities.FormatResourceStringStripCodeAndKeyword("MSBuildVersionMessage", ProjectCollection.DisplayVersion, NativeMethods.FrameworkName));
}
}

/// <summary>
Expand Down