Skip to content

Commit

Permalink
Always respect warning-as-error properties
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rainersigwald authored and github-actions committed Nov 19, 2024
1 parent 43a2496 commit ae660b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Build/BackEnd/Components/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ private async Task<BuildResult> 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
Expand Down Expand Up @@ -1155,7 +1155,7 @@ private async Task<BuildResult> BuildProject()
_requestEntry.Request.BuildEventContext);
}


try
{
HandleProjectStarted(buildCheckManager);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Framework/ProjectStartedEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>? WarningsAsErrors { get; set; }
Expand Down

0 comments on commit ae660b7

Please sign in to comment.