Skip to content

Commit 762f59c

Browse files
authored
Revert "Revert backport pr 10942 to vs17.12" (#11096)
* Revert "Revert backport pr 10942 to vs17.12 (#11088)" This reverts commit bc692d0. * Update Versions.props
1 parent bc692d0 commit 762f59c

File tree

9 files changed

+248
-48
lines changed

9 files changed

+248
-48
lines changed

documentation/wiki/ChangeWaves.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ A wave of features is set to "rotate out" (i.e. become standard functionality) t
2323

2424
## Current Rotation of Change Waves
2525

26+
### 17.14
27+
- [TreatWarningsAsErrors, WarningsAsMessages, WarningsAsErrors, WarningsNotAsErrors are now supported on the engine side of MSBuild](https://github.com/dotnet/msbuild/pull/10942)
28+
2629
### 17.12
2730
- [Log TaskParameterEvent for scalar parameters](https://github.com/dotnet/msbuild/pull/9908)
2831
- [Convert.ToString during a property evaluation uses the InvariantCulture for all types](https://github.com/dotnet/msbuild/pull/9874)

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!-- 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. -->
33
<Project>
44
<PropertyGroup>
5-
<VersionPrefix>17.12.16</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
5+
<VersionPrefix>17.12.17</VersionPrefix><DotNetFinalVersionKind>release</DotNetFinalVersionKind>
66
<PackageValidationBaselineVersion>17.11.4</PackageValidationBaselineVersion>
77
<AssemblyVersion>15.1.0.0</AssemblyVersion>
88
<PreReleaseVersionLabel>preview</PreReleaseVersionLabel>

src/Build.UnitTests/WarningsAsMessagesAndErrors_Tests.cs

Lines changed: 188 additions & 27 deletions
Large diffs are not rendered by default.

src/Build/BackEnd/Components/Logging/LoggingService.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,8 +1666,8 @@ private void RouteBuildEvent(object loggingEvent)
16661666
}
16671667
}
16681668

1669-
// If this is BuildCheck-ed build - add the warnings promotability/demotability to the service
1670-
if (buildEventArgs is ProjectStartedEventArgs projectStartedEvent && this._componentHost.BuildParameters.IsBuildCheckEnabled)
1669+
// Respect warning-promotion properties from the remote project
1670+
if (buildEventArgs is ProjectStartedEventArgs projectStartedEvent)
16711671
{
16721672
AddWarningsAsErrors(projectStartedEvent.BuildEventContext, projectStartedEvent.WarningsAsErrors);
16731673
AddWarningsAsMessages(projectStartedEvent.BuildEventContext, projectStartedEvent.WarningsAsMessages);

src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ private async Task<BuildResult> BuildProject()
11051105
{
11061106
ErrorUtilities.VerifyThrow(_targetBuilder != null, "Target builder is null");
11071107

1108-
// We consider this the entrypoint for the project build for purposes of BuildCheck processing
1108+
// We consider this the entrypoint for the project build for purposes of BuildCheck processing
11091109
bool isRestoring = _requestEntry.RequestConfiguration.GlobalProperties[MSBuildConstants.MSBuildIsRestoring] is not null;
11101110

11111111
var buildCheckManager = isRestoring
@@ -1155,6 +1155,7 @@ private async Task<BuildResult> BuildProject()
11551155
_requestEntry.Request.BuildEventContext);
11561156
}
11571157

1158+
11581159
try
11591160
{
11601161
HandleProjectStarted(buildCheckManager);
@@ -1278,7 +1279,7 @@ private void HandleProjectStarted(IBuildCheckManager buildCheckManager)
12781279
BuildEventContext projectBuildEventContext = _projectLoggingContext?.BuildEventContext;
12791280

12801281
// We can set the warning as errors and messages only after the project logging context has been created (as it creates the new ProjectContextId)
1281-
if (buildCheckManager != null && loggingService != null && projectBuildEventContext != null)
1282+
if (loggingService != null && projectBuildEventContext != null)
12821283
{
12831284
args.WarningsAsErrors = loggingService.GetWarningsAsErrors(projectBuildEventContext).ToHashSet(StringComparer.OrdinalIgnoreCase);
12841285
args.WarningsAsMessages = loggingService.GetWarningsAsMessages(projectBuildEventContext).ToHashSet(StringComparer.OrdinalIgnoreCase);
@@ -1389,29 +1390,35 @@ private void ConfigureWarningsAsErrorsAndMessages()
13891390
// Ensure everything that is required is available at this time
13901391
if (project != null && buildEventContext != null && loggingService != null && buildEventContext.ProjectInstanceId != BuildEventContext.InvalidProjectInstanceId)
13911392
{
1392-
if (String.Equals(project.GetEngineRequiredPropertyValue(MSBuildConstants.TreatWarningsAsErrors)?.Trim(), "true", StringComparison.OrdinalIgnoreCase))
1393+
if (String.Equals(project.GetEngineRequiredPropertyValue(MSBuildConstants.MSBuildPrefix + MSBuildConstants.TreatWarningsAsErrors)?.Trim(), "true", StringComparison.OrdinalIgnoreCase) ||
1394+
(String.Equals(project.GetEngineRequiredPropertyValue(MSBuildConstants.TreatWarningsAsErrors)?.Trim(), "true", StringComparison.OrdinalIgnoreCase) &&
1395+
ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_14)))
13931396
{
13941397
// If <MSBuildTreatWarningsAsErrors was specified then an empty ISet<string> signals the IEventSourceSink to treat all warnings as errors
13951398
loggingService.AddWarningsAsErrors(buildEventContext, new HashSet<string>());
13961399
}
13971400
else
13981401
{
1399-
ISet<string> warningsAsErrors = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsAsErrors));
1402+
ISet<string> warningsAsErrors = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.MSBuildPrefix + MSBuildConstants.WarningsAsErrors),
1403+
project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsAsErrors));
14001404

14011405
if (warningsAsErrors?.Count > 0)
14021406
{
14031407
loggingService.AddWarningsAsErrors(buildEventContext, warningsAsErrors);
14041408
}
14051409
}
14061410

1407-
ISet<string> warningsNotAsErrors = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsNotAsErrors));
1411+
ISet<string> warningsNotAsErrors = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.MSBuildPrefix + MSBuildConstants.WarningsNotAsErrors),
1412+
project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsNotAsErrors));
1413+
14081414

14091415
if (warningsNotAsErrors?.Count > 0)
14101416
{
14111417
loggingService.AddWarningsNotAsErrors(buildEventContext, warningsNotAsErrors);
14121418
}
14131419

1414-
ISet<string> warningsAsMessages = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsAsMessages));
1420+
ISet<string> warningsAsMessages = ParseWarningCodes(project.GetEngineRequiredPropertyValue(MSBuildConstants.MSBuildPrefix + MSBuildConstants.WarningsAsMessages),
1421+
project.GetEngineRequiredPropertyValue(MSBuildConstants.WarningsAsMessages));
14151422

14161423
if (warningsAsMessages?.Count > 0)
14171424
{
@@ -1429,14 +1436,37 @@ private void ConfigureKnownImmutableFolders()
14291436
}
14301437
}
14311438

1432-
private static ISet<string> ParseWarningCodes(string warnings)
1439+
private static ISet<string> ParseWarningCodes(string warnings, string warningsNoPrefix)
14331440
{
1434-
if (String.IsNullOrWhiteSpace(warnings))
1441+
// When this changewave is rotated out and this gets deleted, please consider removing
1442+
// the <MSBuildWarningsAsMessages Condition="'$(MSBuildWarningsAsMessages)'==''">$(NoWarn)</MSBuildWarningsAsMessages>
1443+
// and the two following lines from the msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets
1444+
if (!ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_14))
1445+
{
1446+
warningsNoPrefix = null;
1447+
}
1448+
1449+
HashSet<string> result1 = null;
1450+
if (!String.IsNullOrWhiteSpace(warnings))
1451+
{
1452+
result1 = new HashSet<string>(ExpressionShredder.SplitSemiColonSeparatedList(warnings), StringComparer.OrdinalIgnoreCase);
1453+
}
1454+
HashSet<string> result2 = null;
1455+
if (!String.IsNullOrWhiteSpace(warningsNoPrefix))
1456+
{
1457+
result2 = new HashSet<string>(ExpressionShredder.SplitSemiColonSeparatedList(warningsNoPrefix), StringComparer.OrdinalIgnoreCase);
1458+
}
1459+
1460+
if (result1 != null)
14351461
{
1436-
return null;
1462+
if (result2 != null)
1463+
{
1464+
result1.UnionWith(result2);
1465+
}
1466+
return result1;
14371467
}
14381468

1439-
return new HashSet<string>(ExpressionShredder.SplitSemiColonSeparatedList(warnings), StringComparer.OrdinalIgnoreCase);
1469+
return result2;
14401470
}
14411471

14421472
private sealed class DedicatedThreadsTaskScheduler : TaskScheduler

src/Framework/ChangeWaves.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ internal static class ChangeWaves
2727
{
2828
internal static readonly Version Wave17_10 = new Version(17, 10);
2929
internal static readonly Version Wave17_12 = new Version(17, 12);
30-
internal static readonly Version[] AllWaves = { Wave17_10, Wave17_12 };
30+
internal static readonly Version Wave17_14 = new Version(17, 14);
31+
internal static readonly Version[] AllWaves = { Wave17_10, Wave17_12, Wave17_14 };
3132

3233
/// <summary>
3334
/// Special value indicating that all features behind all Change Waves should be enabled.

src/Framework/ProjectStartedEventArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public IEnumerable? Items
335335
}
336336

337337
// Following 3 properties are intended only for internal transfer - to properly communicate the warn as error/msg
338-
// from the worker node, to the main node - that may be producing the buildcheck diagnostics.
338+
// from the worker node, to the main node.
339339
// They are not going to be in a binlog (at least not as of now).
340340

341341
internal ISet<string>? WarningsAsErrors { get; set; }

src/Shared/Constants.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,30 @@ internal static class MSBuildConstants
2828
/// </summary>
2929
internal const string SdksPath = "MSBuildSDKsPath";
3030

31+
/// <summary>
32+
/// The prefix that was originally used. Now extracted out for the purpose of allowing even the non-prefixed variant.
33+
/// </summary>
34+
internal const string MSBuildPrefix = "MSBuild";
35+
3136
/// <summary>
3237
/// Name of the property that indicates that all warnings should be treated as errors.
3338
/// </summary>
34-
internal const string TreatWarningsAsErrors = "MSBuildTreatWarningsAsErrors";
39+
internal const string TreatWarningsAsErrors = "TreatWarningsAsErrors";
3540

3641
/// <summary>
3742
/// Name of the property that indicates a list of warnings to treat as errors.
3843
/// </summary>
39-
internal const string WarningsAsErrors = "MSBuildWarningsAsErrors";
44+
internal const string WarningsAsErrors = "WarningsAsErrors";
4045

4146
/// <summary>
4247
/// Name of the property that indicates a list of warnings to not treat as errors.
4348
/// </summary>
44-
internal const string WarningsNotAsErrors = "MSBuildWarningsNotAsErrors";
49+
internal const string WarningsNotAsErrors = "WarningsNotAsErrors";
4550

4651
/// <summary>
4752
/// Name of the property that indicates the list of warnings to treat as messages.
4853
/// </summary>
49-
internal const string WarningsAsMessages = "MSBuildWarningsAsMessages";
54+
internal const string WarningsAsMessages = "WarningsAsMessages";
5055

5156
/// <summary>
5257
/// The name of the environment variable that users can specify to override where NuGet assemblies are loaded from in the NuGetSdkResolver.

src/UnitTests.Shared/ObjectModelHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,9 +780,9 @@ public static void BuildProjectExpectSuccess(
780780
/// </summary>
781781
/// <param name="projectContents">The project file content in string format.</param>
782782
/// <returns>The <see cref="MockLogger"/> that was used during evaluation and build.</returns>
783-
public static MockLogger BuildProjectExpectFailure(string projectContents)
783+
public static MockLogger BuildProjectExpectFailure(string projectContents, ITestOutputHelper testOutputHelper = null)
784784
{
785-
MockLogger logger = new MockLogger();
785+
MockLogger logger = new MockLogger(testOutputHelper);
786786
BuildProjectExpectFailure(projectContents, logger);
787787
return logger;
788788
}

0 commit comments

Comments
 (0)