From dfcc34f5dec7246367e99d82e49494b604d84d6c Mon Sep 17 00:00:00 2001 From: MichalPavlik Date: Thu, 19 Sep 2024 11:36:51 +0200 Subject: [PATCH 1/5] Fixes writing unwanted characters to console when TerminalLogger is created directly. --- src/MSBuild/TerminalLogger/TerminalLogger.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MSBuild/TerminalLogger/TerminalLogger.cs b/src/MSBuild/TerminalLogger/TerminalLogger.cs index bcae846e898..1edd23bcf42 100644 --- a/src/MSBuild/TerminalLogger/TerminalLogger.cs +++ b/src/MSBuild/TerminalLogger/TerminalLogger.cs @@ -224,9 +224,8 @@ public ProjectContext(BuildEventContext context) /// /// Default constructor, used by the MSBuild logger infra. /// - public TerminalLogger() + public TerminalLogger() : this(new Terminal()) { - Terminal = new Terminal(); } public TerminalLogger(LoggerVerbosity verbosity) : this() @@ -239,6 +238,7 @@ public TerminalLogger(LoggerVerbosity verbosity) : this() /// internal TerminalLogger(ITerminal terminal) { + NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); Terminal = terminal; _manualRefresh = true; } From 06e9aaa0ce9b3107858f23678c81f3e299dd8c7c Mon Sep 17 00:00:00 2001 From: MichalPavlik Date: Thu, 19 Sep 2024 11:46:56 +0200 Subject: [PATCH 2/5] Removing possible side effect --- src/MSBuild/TerminalLogger/TerminalLogger.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MSBuild/TerminalLogger/TerminalLogger.cs b/src/MSBuild/TerminalLogger/TerminalLogger.cs index 1edd23bcf42..4c9c5011644 100644 --- a/src/MSBuild/TerminalLogger/TerminalLogger.cs +++ b/src/MSBuild/TerminalLogger/TerminalLogger.cs @@ -224,8 +224,10 @@ public ProjectContext(BuildEventContext context) /// /// Default constructor, used by the MSBuild logger infra. /// - public TerminalLogger() : this(new Terminal()) + public TerminalLogger() { + NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); + Terminal = new Terminal(); } public TerminalLogger(LoggerVerbosity verbosity) : this() From 9d0b2787f59c4221101e61eef2f1a7ce6d9ae794 Mon Sep 17 00:00:00 2001 From: MichalPavlik Date: Thu, 19 Sep 2024 16:41:05 +0200 Subject: [PATCH 3/5] Restoring original console state --- src/MSBuild/TerminalLogger/TerminalLogger.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/MSBuild/TerminalLogger/TerminalLogger.cs b/src/MSBuild/TerminalLogger/TerminalLogger.cs index 4c9c5011644..038ec536f6b 100644 --- a/src/MSBuild/TerminalLogger/TerminalLogger.cs +++ b/src/MSBuild/TerminalLogger/TerminalLogger.cs @@ -221,12 +221,13 @@ public ProjectContext(BuildEventContext context) /// private bool _showCommandLine = false; + private uint? _originalConsoleMode; + /// /// Default constructor, used by the MSBuild logger infra. /// public TerminalLogger() { - NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); Terminal = new Terminal(); } @@ -240,7 +241,6 @@ public TerminalLogger(LoggerVerbosity verbosity) : this() /// internal TerminalLogger(ITerminal terminal) { - NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); Terminal = terminal; _manualRefresh = true; } @@ -265,6 +265,8 @@ public void Initialize(IEventSource eventSource, int nodeCount) /// public void Initialize(IEventSource eventSource) { + (_, _, _originalConsoleMode) = NativeMethodsShared.QueryIsScreenAndTryEnableAnsiColorCodes(); + ParseParameters(); eventSource.BuildStarted += BuildStarted; @@ -360,6 +362,8 @@ private bool TryApplyShowCommandLineParameter(string? parameterValue) /// public void Shutdown() { + NativeMethodsShared.RestoreConsoleMode(_originalConsoleMode); + _cts.Cancel(); _refresher?.Join(); Terminal.Dispose(); From 4f6071ce3c70165424c096f89c103b095ba8678b Mon Sep 17 00:00:00 2001 From: MichalPavlik Date: Thu, 19 Sep 2024 18:39:59 +0200 Subject: [PATCH 4/5] Bumping VersionPrefix --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 2d0626911d3..b769b73f572 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.12.0 + 17.12.1 17.11.4 15.1.0.0 preview From 46b7825e0cc3c064aa308407893d2891ccce6f04 Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Thu, 19 Sep 2024 13:04:04 -0500 Subject: [PATCH 5/5] Revert "Bumping VersionPrefix" This reverts commit 4f6071ce3c70165424c096f89c103b095ba8678b. --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index b769b73f572..2d0626911d3 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.12.1 + 17.12.0 17.11.4 15.1.0.0 preview