From 595c4a56494192dd7447c3c9d85e7ede7e74264e Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Fri, 5 Jan 2024 15:40:10 -0600 Subject: [PATCH 1/2] Emit NETSDK1057 at most once in -tl MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #9602 by emitting NETSDK1057 as an immediate message at most once in the TerminalLogger. ```sh-session ❯ dotnet build MSBuild version 17.10.0-dev-24055-01+3500455af for .NET Restore complete (1.1s) You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy Lib1 succeeded (3.1s) → Lib1\bin\Debug\net9.0\Lib1.dll Lib2 succeeded (3.1s) → Lib2\bin\Debug\net9.0\Lib2.dll App succeeded (3.2s) → App\bin\Debug\net9.0\App.dll Build succeeded in 4.5s ``` --- src/MSBuild/TerminalLogger/TerminalLogger.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/MSBuild/TerminalLogger/TerminalLogger.cs b/src/MSBuild/TerminalLogger/TerminalLogger.cs index f317fd6c1b8..b1c1026b760 100644 --- a/src/MSBuild/TerminalLogger/TerminalLogger.cs +++ b/src/MSBuild/TerminalLogger/TerminalLogger.cs @@ -138,6 +138,11 @@ public ProjectContext(BuildEventContext context) /// private bool _manualRefresh; + /// + /// True if we've logged the ".NET SDK is preview" message. + /// + private bool _loggedPreviewMessage; + /// /// List of events the logger needs as parameters to the . /// @@ -570,6 +575,16 @@ private void MessageRaised(object sender, BuildMessageEventArgs e) { RenderImmediateMessage(message); } + + if (e.Code == "NETSDK1057" && !_loggedPreviewMessage) + { + // The SDK will log the high-pri "not-a-warning" message NETSDK1057 + // when it's a preview version up to MaxCPUCount times, but that's + // an implementation detail--the user cares about at most one. + + RenderImmediateMessage(message); + _loggedPreviewMessage = true; + } } } From 4f2c1e70a8a5003898088dd6a0432151c4f0edfa Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Mon, 8 Jan 2024 12:57:53 -0600 Subject: [PATCH 2/2] Update src/MSBuild/TerminalLogger/TerminalLogger.cs Co-authored-by: Ladi Prosek --- src/MSBuild/TerminalLogger/TerminalLogger.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/MSBuild/TerminalLogger/TerminalLogger.cs b/src/MSBuild/TerminalLogger/TerminalLogger.cs index b1c1026b760..10048c7ac19 100644 --- a/src/MSBuild/TerminalLogger/TerminalLogger.cs +++ b/src/MSBuild/TerminalLogger/TerminalLogger.cs @@ -575,8 +575,7 @@ private void MessageRaised(object sender, BuildMessageEventArgs e) { RenderImmediateMessage(message); } - - if (e.Code == "NETSDK1057" && !_loggedPreviewMessage) + else if (e.Code == "NETSDK1057" && !_loggedPreviewMessage) { // The SDK will log the high-pri "not-a-warning" message NETSDK1057 // when it's a preview version up to MaxCPUCount times, but that's