diff --git a/src/Build.UnitTests/BackEnd/MockLoggingService.cs b/src/Build.UnitTests/BackEnd/MockLoggingService.cs index f69b9525340..ff64a18f7f3 100644 --- a/src/Build.UnitTests/BackEnd/MockLoggingService.cs +++ b/src/Build.UnitTests/BackEnd/MockLoggingService.cs @@ -161,6 +161,15 @@ public ISet WarningsAsErrors set; } + /// + /// List of warnings to not treat as errors. + /// + public ISet WarningsNotAsErrors + { + get; + set; + } + /// /// List of warnings to treat as low importance messages. /// diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs index 5773d754834..953d2a817bd 100644 --- a/src/Build/BackEnd/BuildManager/BuildManager.cs +++ b/src/Build/BackEnd/BuildManager/BuildManager.cs @@ -494,6 +494,7 @@ ILoggingService InitializeLoggingService() AppendDebuggingLoggers(_buildParameters.Loggers), _buildParameters.ForwardingLoggers, _buildParameters.WarningsAsErrors, + _buildParameters.WarningsNotAsErrors, _buildParameters.WarningsAsMessages); _nodeManager.RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, loggingService as INodePacketHandler); @@ -2939,7 +2940,7 @@ void OnProjectStartedBody(ProjectStartedEventArgs e) /// /// Creates a logging service around the specified set of loggers. /// - private ILoggingService CreateLoggingService(IEnumerable loggers, IEnumerable forwardingLoggers, ISet warningsAsErrors, ISet warningsAsMessages) + private ILoggingService CreateLoggingService(IEnumerable loggers, IEnumerable forwardingLoggers, ISet warningsAsErrors, ISet warningsNotAsErrors, ISet warningsAsMessages) { Debug.Assert(Monitor.IsEntered(_syncLock)); @@ -2960,6 +2961,7 @@ private ILoggingService CreateLoggingService(IEnumerable loggers, IEnum loggingService.OnProjectStarted += _projectStartedEventHandler; loggingService.OnProjectFinished += _projectFinishedEventHandler; loggingService.WarningsAsErrors = warningsAsErrors; + loggingService.WarningsNotAsErrors = warningsNotAsErrors; loggingService.WarningsAsMessages = warningsAsMessages; try diff --git a/src/Build/BackEnd/BuildManager/BuildParameters.cs b/src/Build/BackEnd/BuildManager/BuildParameters.cs index e625517f2ea..bd4be51a130 100644 --- a/src/Build/BackEnd/BuildManager/BuildParameters.cs +++ b/src/Build/BackEnd/BuildManager/BuildParameters.cs @@ -296,6 +296,7 @@ internal BuildParameters(BuildParameters other, bool resetEnvironment = false) _logTaskInputs = other._logTaskInputs; _logInitialPropertiesAndItems = other._logInitialPropertiesAndItems; WarningsAsErrors = other.WarningsAsErrors == null ? null : new HashSet(other.WarningsAsErrors, StringComparer.OrdinalIgnoreCase); + WarningsNotAsErrors = other.WarningsNotAsErrors == null ? null : new HashSet(other.WarningsNotAsErrors, StringComparer.OrdinalIgnoreCase); WarningsAsMessages = other.WarningsAsMessages == null ? null : new HashSet(other.WarningsAsMessages, StringComparer.OrdinalIgnoreCase); _projectLoadSettings = other._projectLoadSettings; _interactive = other._interactive; @@ -548,6 +549,11 @@ public bool OnlyLogCriticalEvents /// public ISet WarningsAsErrors { get; set; } + /// + /// A list of warnings to not treat as errors. Only has any effect if WarningsAsErrors is empty. + /// + public ISet WarningsNotAsErrors { get; set; } + /// /// A list of warnings to treat as low importance messages. /// diff --git a/src/Build/BackEnd/Components/Logging/ILoggingService.cs b/src/Build/BackEnd/Components/Logging/ILoggingService.cs index bb2fce7940e..48a718af8e6 100644 --- a/src/Build/BackEnd/Components/Logging/ILoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/ILoggingService.cs @@ -163,6 +163,15 @@ ISet WarningsAsErrors set; } + /// + /// Set of warnings to not treat as errors. Only has any effect if WarningsAsErrors is non-null but empty. + /// + ISet WarningsNotAsErrors + { + get; + set; + } + /// /// A list of warnings to treat as low importance messages. /// diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index 33f623a2965..72944def7f5 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -480,6 +480,15 @@ public ISet WarningsAsErrors set; } = null; + /// + /// Get of warnings to not treat as errors. Only has any effect if WarningsAsErrors is empty but not null. + /// + public ISet WarningsNotAsErrors + { + get; + set; + } = null; + /// /// A list of warnings to treat as low importance messages. /// @@ -1744,7 +1753,7 @@ private bool ShouldTreatWarningAsError(BuildWarningEventArgs warningEvent) { // Global warnings as errors apply to all projects. If the list is empty or contains the code, the warning should be treated as an error // - if (WarningsAsErrors.Count == 0 || WarningsAsErrors.Contains(warningEvent.Code)) + if ((WarningsAsErrors.Count == 0 && (WarningsNotAsErrors is null || !WarningsNotAsErrors.Contains(warningEvent.Code))) || WarningsAsErrors.Contains(warningEvent.Code)) { return true; } diff --git a/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt index 9281b0c3cf8..9274dfbec17 100644 --- a/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt @@ -11,3 +11,5 @@ Microsoft.Build.FileSystem.IDirectoryCache.FileExists(string path) -> bool Microsoft.Build.FileSystem.IDirectoryCacheFactory Microsoft.Build.FileSystem.IDirectoryCacheFactory.GetDirectoryCacheForEvaluation(int evaluationId) -> Microsoft.Build.FileSystem.IDirectoryCache static Microsoft.Build.Globbing.CompositeGlob.Create(System.Collections.Generic.IEnumerable globs) -> Microsoft.Build.Globbing.IMSBuildGlob +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.get -> System.Collections.Generic.ISet +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.set -> void diff --git a/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 218e7d4593d..8a16c8197ba 100644 --- a/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -10,4 +10,6 @@ Microsoft.Build.FileSystem.IDirectoryCache.EnumerateFiles(string path, Microsoft.Build.FileSystem.IDirectoryCache.FileExists(string path) -> bool Microsoft.Build.FileSystem.IDirectoryCacheFactory Microsoft.Build.FileSystem.IDirectoryCacheFactory.GetDirectoryCacheForEvaluation(int evaluationId) -> Microsoft.Build.FileSystem.IDirectoryCache -static Microsoft.Build.Globbing.CompositeGlob.Create(System.Collections.Generic.IEnumerable globs) -> Microsoft.Build.Globbing.IMSBuildGlob \ No newline at end of file +static Microsoft.Build.Globbing.CompositeGlob.Create(System.Collections.Generic.IEnumerable globs) -> Microsoft.Build.Globbing.IMSBuildGlob +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.get -> System.Collections.Generic.ISet +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.set -> void \ No newline at end of file diff --git a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs index fb53c311fad..1edc8e3fb76 100644 --- a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs +++ b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs @@ -996,6 +996,7 @@ public void InvalidToolsVersionErrors() new StringWriter(), false, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null, enableRestore: false, profilerLogger: null, diff --git a/src/MSBuild/CommandLineSwitches.cs b/src/MSBuild/CommandLineSwitches.cs index 07bfbacf461..e6709d9a4e4 100644 --- a/src/MSBuild/CommandLineSwitches.cs +++ b/src/MSBuild/CommandLineSwitches.cs @@ -94,6 +94,7 @@ internal enum ParameterizedSwitch Preprocess, Targets, WarningsAsErrors, + WarningsNotAsErrors, WarningsAsMessages, BinaryLogger, Restore, @@ -263,6 +264,7 @@ bool emptyParametersAllowed new ParameterizedSwitchInfo( new string[] { "preprocess", "pp" }, ParameterizedSwitch.Preprocess, null, false, null, true, false ), new ParameterizedSwitchInfo( new string[] { "targets", "ts" }, ParameterizedSwitch.Targets, null, false, null, true, false ), new ParameterizedSwitchInfo( new string[] { "warnaserror", "err" }, ParameterizedSwitch.WarningsAsErrors, null, true, null, true, true ), + new ParameterizedSwitchInfo( new string[] { "warnnotaserror", "err" }, ParameterizedSwitch.WarningsNotAsErrors, null, true, "MissingWarnNotAsErrorParameterError", true, true ), new ParameterizedSwitchInfo( new string[] { "warnasmessage", "nowarn" }, ParameterizedSwitch.WarningsAsMessages, null, true, "MissingWarnAsMessageParameterError", true, false ), new ParameterizedSwitchInfo( new string[] { "binarylogger", "bl" }, ParameterizedSwitch.BinaryLogger, null, false, null, true, false ), new ParameterizedSwitchInfo( new string[] { "restore", "r" }, ParameterizedSwitch.Restore, null, false, null, true, false ), diff --git a/src/MSBuild/Resources/Strings.resx b/src/MSBuild/Resources/Strings.resx index 61b9471ba63..93bbda2251b 100644 --- a/src/MSBuild/Resources/Strings.resx +++ b/src/MSBuild/Resources/Strings.resx @@ -1258,6 +1258,14 @@ Copyright (C) Microsoft Corporation. All rights reserved. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1053: Provided filename is not valid. {0} @@ -1294,7 +1302,7 @@ Copyright (C) Microsoft Corporation. All rights reserved. diff --git a/src/MSBuild/Resources/xlf/Strings.cs.xlf b/src/MSBuild/Resources/xlf/Strings.cs.xlf index 3391a53a640..e38945e5d11 100644 --- a/src/MSBuild/Resources/xlf/Strings.cs.xlf +++ b/src/MSBuild/Resources/xlf/Strings.cs.xlf @@ -1211,6 +1211,15 @@ Copyright (C) Microsoft Corporation. Všechna práva vyhrazena. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.de.xlf b/src/MSBuild/Resources/xlf/Strings.de.xlf index 63493f136ce..321a5103ec1 100644 --- a/src/MSBuild/Resources/xlf/Strings.de.xlf +++ b/src/MSBuild/Resources/xlf/Strings.de.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.es.xlf b/src/MSBuild/Resources/xlf/Strings.es.xlf index 956059968ba..4447aa52cb2 100644 --- a/src/MSBuild/Resources/xlf/Strings.es.xlf +++ b/src/MSBuild/Resources/xlf/Strings.es.xlf @@ -1212,6 +1212,15 @@ Copyright (C) Microsoft Corporation. Todos los derechos reservados. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.fr.xlf b/src/MSBuild/Resources/xlf/Strings.fr.xlf index a0aa66f7a84..96d635a579a 100644 --- a/src/MSBuild/Resources/xlf/Strings.fr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.fr.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation. Tous droits réservés. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.it.xlf b/src/MSBuild/Resources/xlf/Strings.it.xlf index 200a7a77dae..659c0d869e5 100644 --- a/src/MSBuild/Resources/xlf/Strings.it.xlf +++ b/src/MSBuild/Resources/xlf/Strings.it.xlf @@ -1225,6 +1225,15 @@ Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.ja.xlf b/src/MSBuild/Resources/xlf/Strings.ja.xlf index 453bbc44766..99db478d0e7 100644 --- a/src/MSBuild/Resources/xlf/Strings.ja.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ja.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation.All rights reserved. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.ko.xlf b/src/MSBuild/Resources/xlf/Strings.ko.xlf index e57ed62661a..44dd1a06b48 100644 --- a/src/MSBuild/Resources/xlf/Strings.ko.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ko.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.pl.xlf b/src/MSBuild/Resources/xlf/Strings.pl.xlf index c1e63e21afe..761090aa4ff 100644 --- a/src/MSBuild/Resources/xlf/Strings.pl.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pl.xlf @@ -1217,6 +1217,15 @@ Copyright (C) Microsoft Corporation. Wszelkie prawa zastrzeżone. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf index e8293005192..9a1cd5ece69 100644 --- a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf @@ -1204,6 +1204,15 @@ isoladamente. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.ru.xlf b/src/MSBuild/Resources/xlf/Strings.ru.xlf index d5f02251680..8023d34d63c 100644 --- a/src/MSBuild/Resources/xlf/Strings.ru.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ru.xlf @@ -1202,6 +1202,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.tr.xlf b/src/MSBuild/Resources/xlf/Strings.tr.xlf index 06ed57c5523..aebe94e4ede 100644 --- a/src/MSBuild/Resources/xlf/Strings.tr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.tr.xlf @@ -1207,6 +1207,15 @@ Telif Hakkı (C) Microsoft Corporation. Tüm hakları saklıdır. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf index 3a68a4c3a6b..50773c2d428 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf index 5992ad480da..306ccf9036c 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf @@ -1203,6 +1203,15 @@ Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。 {StrBegin="MSBUILD : error MSB1016: "}UE: This happens if the user does something like "msbuild.exe -verbosity". The user must pass in a verbosity level after the switch e.g. "msbuild.exe -verbosity:detailed". LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + + + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes to keep as warnings despite a global -warnaserror when using the -warnNotAsError switch. + + {StrBegin="MSBUILD : error MSB1060: "} + UE: This happens if the user does something like "msbuild.exe -warnNotAsError:" without any codes. + LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 05e4e08e912..636479d334c 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -557,6 +557,7 @@ string[] commandLine TextWriter targetsWriter = null; bool detailedSummary = false; ISet warningsAsErrors = null; + ISet warningsNotAsErrors = null; ISet warningsAsMessages = null; bool enableRestore = Traits.Instance.EnableRestoreFirst; ProfilerLogger profilerLogger = null; @@ -590,6 +591,7 @@ string[] commandLine ref targetsWriter, ref detailedSummary, ref warningsAsErrors, + ref warningsNotAsErrors, ref warningsAsMessages, ref enableRestore, ref interactive, @@ -669,6 +671,7 @@ string[] commandLine targetsWriter, detailedSummary, warningsAsErrors, + warningsNotAsErrors, warningsAsMessages, enableRestore, profilerLogger, @@ -996,6 +999,7 @@ internal static bool BuildProject TextWriter targetsWriter, bool detailedSummary, ISet warningsAsErrors, + ISet warningsNotAsErrors, ISet warningsAsMessages, bool enableRestore, ProfilerLogger profilerLogger, @@ -1167,6 +1171,7 @@ string outputResultsCache parameters.DetailedSummary = detailedSummary; parameters.LogTaskInputs = logTaskInputs; parameters.WarningsAsErrors = warningsAsErrors; + parameters.WarningsNotAsErrors = warningsNotAsErrors; parameters.WarningsAsMessages = warningsAsMessages; parameters.Interactive = interactive; parameters.IsolateProjects = isolateProjects; @@ -2103,6 +2108,7 @@ private static bool ProcessCommandLineSwitches ref TextWriter targetsWriter, ref bool detailedSummary, ref ISet warningsAsErrors, + ref ISet warningsNotAsErrors, ref ISet warningsAsMessages, ref bool enableRestore, ref bool interactive, @@ -2220,6 +2226,7 @@ bool recursing ref targetsWriter, ref detailedSummary, ref warningsAsErrors, + ref warningsNotAsErrors, ref warningsAsMessages, ref enableRestore, ref interactive, @@ -2271,6 +2278,8 @@ bool recursing warningsAsErrors = ProcessWarnAsErrorSwitch(commandLineSwitches); + warningsNotAsErrors = ProcessWarnNotAsErrorSwitch(commandLineSwitches); + warningsAsMessages = ProcessWarnAsMessageSwitch(commandLineSwitches); if (commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.Restore)) @@ -2493,18 +2502,18 @@ internal static TextWriter ProcessTargetsSwitch(string[] parameters) return writer; } - internal static ISet ProcessWarnAsErrorSwitch(CommandLineSwitches commandLineSwitches) + private static ISet ProcessWarningRelatedSwitch(CommandLineSwitches commandLineSwitches, CommandLineSwitches.ParameterizedSwitch warningSwitch) { // TODO: Parse an environment variable as well? - if (!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.WarningsAsErrors)) + if (!commandLineSwitches.IsParameterizedSwitchSet(warningSwitch)) { return null; } - string[] parameters = commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.WarningsAsErrors]; + string[] parameters = commandLineSwitches[warningSwitch]; - ISet warningsAsErrors = new HashSet(StringComparer.OrdinalIgnoreCase); + ISet warningSwitches = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (string code in parameters .SelectMany(parameter => parameter?.Split(s_commaSemicolon, StringSplitOptions.RemoveEmptyEntries) ?? new string[] { null })) @@ -2513,37 +2522,30 @@ internal static ISet ProcessWarnAsErrorSwitch(CommandLineSwitches comman { // An empty /warnaserror is added as "null". In this case, the list is cleared // so that all warnings are treated errors - warningsAsErrors.Clear(); + warningSwitches.Clear(); } else if (!string.IsNullOrWhiteSpace(code)) { - warningsAsErrors.Add(code.Trim()); + warningSwitches.Add(code.Trim()); } } - return warningsAsErrors; + return warningSwitches; } - internal static ISet ProcessWarnAsMessageSwitch(CommandLineSwitches commandLineSwitches) + internal static ISet ProcessWarnAsErrorSwitch(CommandLineSwitches commandLineSwitches) { - if (!commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.WarningsAsMessages)) - { - return null; - } - - string[] parameters = commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.WarningsAsMessages]; - - ISet warningsAsMessages = new HashSet(StringComparer.OrdinalIgnoreCase); + return ProcessWarningRelatedSwitch(commandLineSwitches, CommandLineSwitches.ParameterizedSwitch.WarningsAsErrors); + } - foreach (string code in parameters - .SelectMany(parameter => parameter?.Split(s_commaSemicolon, StringSplitOptions.RemoveEmptyEntries)) - .Where(i => !string.IsNullOrWhiteSpace(i)) - .Select(i => i.Trim())) - { - warningsAsMessages.Add(code); - } + internal static ISet ProcessWarnAsMessageSwitch(CommandLineSwitches commandLineSwitches) + { + return ProcessWarningRelatedSwitch(commandLineSwitches, CommandLineSwitches.ParameterizedSwitch.WarningsAsMessages); + } - return warningsAsMessages; + internal static ISet ProcessWarnNotAsErrorSwitch(CommandLineSwitches commandLineSwitches) + { + return ProcessWarningRelatedSwitch(commandLineSwitches, CommandLineSwitches.ParameterizedSwitch.WarningsNotAsErrors); } internal static bool ProcessBooleanSwitch(string[] parameters, bool defaultValue, string resourceName)