Skip to content

Commit

Permalink
[vs17.12] Always respect warning-as-error properties (#10999)
Browse files Browse the repository at this point in the history
Backport of #10892 to vs17.12

Work item (Internal use): 

### Summary

Respect warning-as-error settings configured per-project when
`-warnaserror` is passed on the command line.

### Customer Impact

Suppressing warnings is unnecessarily complicated and fails for
confusing reasons.

### Regression?

No, this behavior is longstanding, but the severity is higher with NuGet
Audit because NuGet advises configuring warning-as-warning for audit
warning codes.

### Testing

Automated and targeted scenario tests.

### Risk

Low: makes an existing opt-in codepath default.
  • Loading branch information
surayya-MS authored Nov 21, 2024
2 parents 6ee3f9a + 0da1063 commit 1cce779
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the MIT license. See License.txt in the project root for full license information. -->
<Project>
<PropertyGroup>
<VersionPrefix>17.12.10</VersionPrefix>
<VersionPrefix>17.12.12</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<DotNetFinalVersionKind>release</DotNetFinalVersionKind>
<PackageValidationBaselineVersion>17.11.4</PackageValidationBaselineVersion>
<AssemblyVersion>15.1.0.0</AssemblyVersion>
Expand Down
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 1cce779

Please sign in to comment.