From ae660b71233ef87659e4eb68d34a20f0524fa86d Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Thu, 10 Oct 2024 11:26:22 -0500 Subject: [PATCH 1/2] Always respect warning-as-error properties Remote (built in another node) projects were not respecting MSBuildWarningsNotAsErrors configured in the projects, when the API or CLI `-warnaserror` option was enabled. Fixes #10874. --- src/Build/BackEnd/Components/Logging/LoggingService.cs | 4 ++-- .../BackEnd/Components/RequestBuilder/RequestBuilder.cs | 6 +++--- src/Framework/ProjectStartedEventArgs.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index b5ed777d161..cfc289ad30e 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -1666,8 +1666,8 @@ private void RouteBuildEvent(object loggingEvent) } } - // If this is BuildCheck-ed build - add the warnings promotability/demotability to the service - if (buildEventArgs is ProjectStartedEventArgs projectStartedEvent && this._componentHost.BuildParameters.IsBuildCheckEnabled) + // Respect warning-promotion properties from the remote project + if (buildEventArgs is ProjectStartedEventArgs projectStartedEvent) { AddWarningsAsErrors(projectStartedEvent.BuildEventContext, projectStartedEvent.WarningsAsErrors); AddWarningsAsMessages(projectStartedEvent.BuildEventContext, projectStartedEvent.WarningsAsMessages); diff --git a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs index 5df61cc392b..99abd0ef00f 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs @@ -1105,7 +1105,7 @@ private async Task BuildProject() { ErrorUtilities.VerifyThrow(_targetBuilder != null, "Target builder is null"); - // We consider this the entrypoint for the project build for purposes of BuildCheck processing + // We consider this the entrypoint for the project build for purposes of BuildCheck processing bool isRestoring = _requestEntry.RequestConfiguration.GlobalProperties[MSBuildConstants.MSBuildIsRestoring] is not null; var buildCheckManager = isRestoring @@ -1155,7 +1155,7 @@ private async Task BuildProject() _requestEntry.Request.BuildEventContext); } - + try { HandleProjectStarted(buildCheckManager); @@ -1279,7 +1279,7 @@ private void HandleProjectStarted(IBuildCheckManager buildCheckManager) BuildEventContext projectBuildEventContext = _projectLoggingContext?.BuildEventContext; // We can set the warning as errors and messages only after the project logging context has been created (as it creates the new ProjectContextId) - if (buildCheckManager != null && loggingService != null && projectBuildEventContext != null) + if (loggingService != null && projectBuildEventContext != null) { args.WarningsAsErrors = loggingService.GetWarningsAsErrors(projectBuildEventContext).ToHashSet(StringComparer.OrdinalIgnoreCase); args.WarningsAsMessages = loggingService.GetWarningsAsMessages(projectBuildEventContext).ToHashSet(StringComparer.OrdinalIgnoreCase); diff --git a/src/Framework/ProjectStartedEventArgs.cs b/src/Framework/ProjectStartedEventArgs.cs index 8dcf4330fb0..9d2bb8345ac 100644 --- a/src/Framework/ProjectStartedEventArgs.cs +++ b/src/Framework/ProjectStartedEventArgs.cs @@ -335,7 +335,7 @@ public IEnumerable? Items } // Following 3 properties are intended only for internal transfer - to properly communicate the warn as error/msg - // from the worker node, to the main node - that may be producing the buildcheck diagnostics. + // from the worker node, to the main node. // They are not going to be in a binlog (at least not as of now). internal ISet? WarningsAsErrors { get; set; } From 264677e8e5db3fdb08063505aa691d067921e338 Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Wed, 20 Nov 2024 16:19:55 -0600 Subject: [PATCH 2/2] Bump version --- eng/Versions.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Versions.props b/eng/Versions.props index 299c910ffbd..09e725ae280 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.12.9release + 17.12.12release 17.11.4 15.1.0.0 preview