From 7d926d7ab5d864f40853957e5af69c05c5383295 Mon Sep 17 00:00:00 2001 From: Forgind Date: Tue, 15 Feb 2022 17:45:48 -0800 Subject: [PATCH] Implement warnnotaserror Fixes #3062 (#7309) Fixes #3062 Context We previously had warnaserror (and a property for it) that, when you specified error codes, upgraded those error codes from warnings to errors. If you just left it empty, it upgraded all warnings to errors. (Null meant don't upgrade.) This adds that you can ask for all error codes to be upgraded, then downgrade just a few of them (via codes) back to warnings. Changes Made Implement WarnNotAsError both as a command line switch and as a property. Testing Added a unit test. Tried it out from the command line. --- .../BackEnd/MockLoggingService.cs | 19 +++ .../BackEnd/TaskHostConfiguration_Tests.cs | 16 ++ .../BackEnd/BuildManager/BuildManager.cs | 4 +- .../BackEnd/BuildManager/BuildParameters.cs | 6 + .../Components/Logging/ILoggingService.cs | 31 +++- .../Components/Logging/LoggingService.cs | 157 ++++++++++++------ .../Components/Logging/TaskLoggingContext.cs | 5 + .../RequestBuilder/RequestBuilder.cs | 10 +- .../Components/RequestBuilder/TaskHost.cs | 27 ++- .../Instance/TaskFactories/TaskHostTask.cs | 1 + .../PublicAPI/net/PublicAPI.Unshipped.txt | 2 + .../netstandard/PublicAPI.Unshipped.txt | 2 + .../CommandLineSwitches_Tests.cs | 1 + src/MSBuild.UnitTests/XMake_Tests.cs | 27 ++- src/MSBuild/CommandLineSwitches.cs | 2 + src/MSBuild/OutOfProcTaskHostNode.cs | 10 +- src/MSBuild/Resources/Strings.resx | 30 +++- src/MSBuild/Resources/xlf/Strings.cs.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.de.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.es.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.fr.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.it.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.ja.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.ko.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.pl.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.pt-BR.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.ru.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.tr.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf | 40 +++++ src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf | 40 +++++ src/MSBuild/XMake.cs | 114 +++++++------ src/Shared/Constants.cs | 5 + src/Shared/TaskHostConfiguration.cs | 21 +++ 33 files changed, 892 insertions(+), 118 deletions(-) diff --git a/src/Build.UnitTests/BackEnd/MockLoggingService.cs b/src/Build.UnitTests/BackEnd/MockLoggingService.cs index f69b9525340..bed66bdaaf2 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. /// @@ -240,6 +249,11 @@ public void AddWarningsAsErrors(BuildEventContext buildEventContext, ISet codes) + { + throw new NotImplementedException(); + } + /// /// Registers a distributed logger. /// @@ -609,6 +623,11 @@ public ICollection GetWarningsAsErrors(BuildEventContext context) throw new NotImplementedException(); } + public ICollection GetWarningsNotAsErrors(BuildEventContext context) + { + throw new NotImplementedException(); + } + public ICollection GetWarningsAsMessages(BuildEventContext context) { throw new NotImplementedException(); diff --git a/src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs b/src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs index 87905c53e65..c885fbea105 100644 --- a/src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs +++ b/src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs @@ -61,6 +61,7 @@ public void ConstructorWithNullName() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); } ); @@ -96,6 +97,7 @@ public void ConstructorWithEmptyName() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); } ); @@ -131,6 +133,7 @@ public void ConstructorWithNullLocation() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); } ); @@ -168,6 +171,7 @@ public void ConstructorWithEmptyLocation() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); } ); @@ -203,6 +207,7 @@ public void TestValidConstructors() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); TaskHostConfiguration config2 = new TaskHostConfiguration( @@ -228,6 +233,7 @@ public void TestValidConstructors() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); IDictionary parameters = new Dictionary(); @@ -254,6 +260,7 @@ public void TestValidConstructors() taskParameters: parameters, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); IDictionary parameters2 = new Dictionary(); @@ -285,6 +292,7 @@ public void TestValidConstructors() taskParameters: parameters2, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); HashSet WarningsAsErrors = new HashSet(); @@ -316,6 +324,7 @@ public void TestValidConstructors() taskParameters: parameters2, globalParameters: null, warningsAsErrors: WarningsAsErrors, + warningsNotAsErrors: null, warningsAsMessages: null); } @@ -354,6 +363,7 @@ public void TestTranslationWithNullDictionary() taskParameters: null, globalParameters: expectedGlobalProperties, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -399,6 +409,7 @@ public void TestTranslationWithEmptyDictionary() taskParameters: new Dictionary(), globalParameters: new Dictionary(), warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -449,6 +460,7 @@ public void TestTranslationWithValueTypesInDictionary() taskParameters: parameters, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -497,6 +509,7 @@ public void TestTranslationWithITaskItemInDictionary() taskParameters: parameters, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -544,6 +557,7 @@ public void TestTranslationWithITaskItemArrayInDictionary() taskParameters: parameters, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -598,6 +612,7 @@ public void TestTranslationWithWarningsAsErrors() taskParameters: null, globalParameters: null, warningsAsErrors: WarningsAsErrors, + warningsNotAsErrors: null, warningsAsMessages: null); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); @@ -647,6 +662,7 @@ public void TestTranslationWithWarningsAsMessages() taskParameters: null, globalParameters: null, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: WarningsAsMessages); ((ITranslatable)config).Translate(TranslationHelpers.GetWriteTranslator()); diff --git a/src/Build/BackEnd/BuildManager/BuildManager.cs b/src/Build/BackEnd/BuildManager/BuildManager.cs index 272f0df9705..250c50ae06a 100644 --- a/src/Build/BackEnd/BuildManager/BuildManager.cs +++ b/src/Build/BackEnd/BuildManager/BuildManager.cs @@ -493,6 +493,7 @@ ILoggingService InitializeLoggingService() AppendDebuggingLoggers(_buildParameters.Loggers), _buildParameters.ForwardingLoggers, _buildParameters.WarningsAsErrors, + _buildParameters.WarningsNotAsErrors, _buildParameters.WarningsAsMessages); _nodeManager.RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, loggingService as INodePacketHandler); @@ -2938,7 +2939,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)); @@ -2959,6 +2960,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 36bab2c193a..1fec6f1c510 100644 --- a/src/Build/BackEnd/BuildManager/BuildParameters.cs +++ b/src/Build/BackEnd/BuildManager/BuildParameters.cs @@ -294,6 +294,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; @@ -543,6 +544,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..c261563d0e7 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. /// @@ -234,6 +243,13 @@ MessageImportance MinimumRequiredMessageImportance /// The list of warning codes to treat as errors. void AddWarningsAsErrors(BuildEventContext buildEventContext, ISet codes); + /// + /// Adds a set of warning codes to not treat as errors for the specified project instance ID. + /// + /// A to associate with the list of warning codes. + /// The list of warning codes not to treat as errors. + void AddWarningsNotAsErrors(BuildEventContext buildEventContext, ISet codes); + /// /// Determines if the specified submission has logged an errors. /// @@ -242,17 +258,24 @@ MessageImportance MinimumRequiredMessageImportance bool HasBuildSubmissionLoggedErrors(int submissionId); /// - /// Returns a hashset of warnings to be logged as errors for the specified project instance ID. + /// Get the warnings that will be promoted to errors for the specified context. /// /// The build context through which warnings will be logged as errors. - /// A Hashset containing warning codes that should be treated as errors. + /// A collection of warning codes that should be treated as errors. ICollection GetWarningsAsErrors(BuildEventContext context); /// - /// Returns a hashset of warnings to be logged as messages for the specified project instance ID. + /// Get the warnings that will not be promoted to error for the specified context. + /// + /// The build context through which warnings will not be logged as errors. + /// A collection of warning codes that should not be treated as errors. + ICollection GetWarningsNotAsErrors(BuildEventContext context); + + /// + /// Get the warnings that will be demoted to messages for the specified context. /// /// The build context through which warnings will be logged as errors. - /// A Hashset containing warning codes that should be treated as messages. + /// A collection of warning codes that should be treated as messages. ICollection GetWarningsAsMessages(BuildEventContext context); #region Register diff --git a/src/Build/BackEnd/Components/Logging/LoggingService.cs b/src/Build/BackEnd/Components/Logging/LoggingService.cs index fd9becd085c..6f1f5152377 100644 --- a/src/Build/BackEnd/Components/Logging/LoggingService.cs +++ b/src/Build/BackEnd/Components/Logging/LoggingService.cs @@ -220,6 +220,11 @@ internal partial class LoggingService : ILoggingService, INodePacketHandler, IBu /// private IDictionary> _warningsAsErrorsByProject; + /// + /// A list of warnings to not to be promoted to errors for an associated . + /// + private IDictionary> _warningsNotAsErrorsByProject; + /// /// A list of warnings to treat as messages for an associated . /// @@ -480,6 +485,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. /// @@ -563,83 +577,115 @@ public bool HasBuildSubmissionLoggedErrors(int submissionId) } /// - /// Returns a hashset of warnings to be logged as errors for the specified build context. + /// Returns a collection of warnings to be logged as errors for the specified build context. /// /// The build context through which warnings will be logged as errors. /// /// public ICollection GetWarningsAsErrors(BuildEventContext context) { - int key = GetWarningsAsErrorOrMessageKey(context); - - if (_warningsAsErrorsByProject != null && _warningsAsErrorsByProject.TryGetValue(key, out ISet warningsAsErrors)) - { - if (WarningsAsErrors != null) - { - warningsAsErrors.UnionWith(WarningsAsErrors); - } + return GetWarningsForProject(context, _warningsAsErrorsByProject, WarningsAsErrors); + } - return warningsAsErrors; - } - else - { - return WarningsAsErrors; - } + /// + /// Returns a collection of warnings not to be logged as errors for the specified build context. + /// + /// The build context through which warnings will be kept as warnings. + /// + /// + public ICollection GetWarningsNotAsErrors(BuildEventContext context) + { + return GetWarningsForProject(context, _warningsNotAsErrorsByProject, WarningsNotAsErrors); } + /// + /// Returns a collection of warnings to be demoted to messages for the specified build context. + /// + /// The build context through which warnings will be logged as messages. + /// + /// public ICollection GetWarningsAsMessages(BuildEventContext context) + { + return GetWarningsForProject(context, _warningsAsMessagesByProject, WarningsAsMessages); + } + + /// + /// Helper method that unifies the logic for GetWarningsAsErrors, GetWarningsNotAsErrors, and GetWarningsAsMessages. + /// Specifically, this method returns a collection of codes that, within the context of a particular project, should + /// be treated specially. These tend to come from setting the associated properties in the project file. These are + /// added to previously known codes as necessary. + /// + /// The specific context in which to consider special treatment for warnings. + /// A dictionary of all warnings to be treated special by for which projects. + /// Warning codes we already know should be promoted, demoted, or not promoted as relevant. + /// + private ICollection GetWarningsForProject(BuildEventContext context, IDictionary> warningsByProject, ISet warnings) { int key = GetWarningsAsErrorOrMessageKey(context); - if (_warningsAsMessagesByProject != null && _warningsAsMessagesByProject.TryGetValue(key, out ISet warningsAsMessages)) + if (warningsByProject != null && warningsByProject.TryGetValue(key, out ISet newWarnings)) { - if (WarningsAsMessages != null) + if (warnings != null) { - warningsAsMessages.UnionWith(WarningsAsMessages); + newWarnings.UnionWith(warnings); } - return warningsAsMessages; + return newWarnings; } else { - return WarningsAsMessages; + return warnings; } } + /// + /// Adds warning codes that should be treated as errors to the known set. + /// + /// The context in which to consider possible warnings to be promoted. + /// Codes to promote public void AddWarningsAsErrors(BuildEventContext buildEventContext, ISet codes) { - lock (_lockObject) - { - int key = GetWarningsAsErrorOrMessageKey(buildEventContext); - - if (_warningsAsErrorsByProject == null) - { - _warningsAsErrorsByProject = new ConcurrentDictionary>(); - } + AddWarningsAsMessagesOrErrors(ref _warningsAsErrorsByProject, buildEventContext, codes); + } - if (!_warningsAsErrorsByProject.ContainsKey(key)) - { - // The same project instance can be built multiple times with different targets. In this case the codes have already been added - _warningsAsErrorsByProject[key] = new HashSet(codes, StringComparer.OrdinalIgnoreCase); - } - } + /// + /// Adds warning codes that should not be treated as errors even if WarnAsError is empty (specifying that all warnings should be promoted). + /// + /// The context in which to consider warnings not to be promoted. + /// Codes not to promote + public void AddWarningsNotAsErrors(BuildEventContext buildEventContext, ISet codes) + { + AddWarningsAsMessagesOrErrors(ref _warningsNotAsErrorsByProject, buildEventContext, codes); } + /// + /// Adds warning codes that should be treated as messages. + /// + /// The context in which to consider warnings to be demoted. + /// Codes to demote public void AddWarningsAsMessages(BuildEventContext buildEventContext, ISet codes) + { + AddWarningsAsMessagesOrErrors(ref _warningsAsMessagesByProject, buildEventContext, codes); + } + + /// + /// Adds warning codes to be treated or not treated as warnings or errors to the set of project-specific codes. + /// + /// Dictionary with what warnings are currently known (by project) that we will add to. + /// Context for the project to be added + /// Codes to add + private void AddWarningsAsMessagesOrErrors(ref IDictionary> warningsByProject, BuildEventContext buildEventContext, ISet codes) { lock (_lockObject) { int key = GetWarningsAsErrorOrMessageKey(buildEventContext); - if (_warningsAsMessagesByProject == null) - { - _warningsAsMessagesByProject = new ConcurrentDictionary>(); - } + warningsByProject ??= new ConcurrentDictionary>(); - if (!_warningsAsMessagesByProject.ContainsKey(key)) + if (!warningsByProject.ContainsKey(key)) { // The same project instance can be built multiple times with different targets. In this case the codes have already been added - _warningsAsMessagesByProject[key] = new HashSet(codes, StringComparer.OrdinalIgnoreCase); + warningsByProject[key] = new HashSet(codes, StringComparer.OrdinalIgnoreCase); } } } @@ -1471,8 +1517,10 @@ private void RouteBuildEvent(object loggingEvent) if (loggingEvent is ProjectFinishedEventArgs projectFinishedEvent && projectFinishedEvent.BuildEventContext != null) { - _warningsAsErrorsByProject?.Remove(GetWarningsAsErrorOrMessageKey(projectFinishedEvent)); - _warningsAsMessagesByProject?.Remove(GetWarningsAsErrorOrMessageKey(projectFinishedEvent)); + int key = GetWarningsAsErrorOrMessageKey(projectFinishedEvent); + _warningsAsErrorsByProject?.Remove(key); + _warningsNotAsErrorsByProject?.Remove(key); + _warningsAsMessagesByProject?.Remove(key); } if (loggingEvent is BuildEventArgs loggingEventBuildArgs) @@ -1712,14 +1760,12 @@ private string GetAndVerifyProjectFileFromContext(BuildEventContext context) private bool ShouldTreatWarningAsMessage(BuildWarningEventArgs warningEvent) { // This only applies if the user specified /nowarn at the command-line or added the warning code through the object model - // if (WarningsAsMessages?.Contains(warningEvent.Code) == true) { return true; } // This only applies if the user specified and there is a valid ProjectInstanceId - // if (_warningsAsMessagesByProject != null && warningEvent.BuildEventContext != null && warningEvent.BuildEventContext.ProjectInstanceId != BuildEventContext.InvalidProjectInstanceId) { if (_warningsAsMessagesByProject.TryGetValue(GetWarningsAsErrorOrMessageKey(warningEvent), out ISet codesByProject)) @@ -1731,6 +1777,13 @@ private bool ShouldTreatWarningAsMessage(BuildWarningEventArgs warningEvent) return false; } + private bool WarningAsErrorNotOverriden(BuildWarningEventArgs warningEvent) + { + int key = GetWarningsAsErrorOrMessageKey(warningEvent); + + return WarningsNotAsErrors?.Contains(warningEvent.Code) != true && !(_warningsNotAsErrorsByProject?.TryGetValue(key, out ISet notToError) == true && notToError.Contains(warningEvent.Code)); + } + /// /// Determines if the specified warning should be treated as an error. /// @@ -1739,12 +1792,10 @@ private bool ShouldTreatWarningAsMessage(BuildWarningEventArgs warningEvent) private bool ShouldTreatWarningAsError(BuildWarningEventArgs warningEvent) { // This only applies if the user specified /warnaserror from the command-line or added an empty set through the object model - // if (WarningsAsErrors != null) { // 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 && WarningAsErrorNotOverriden(warningEvent)) || WarningsAsErrors.Contains(warningEvent.Code)) { return true; } @@ -1752,17 +1803,19 @@ private bool ShouldTreatWarningAsError(BuildWarningEventArgs warningEvent) // This only applies if the user specified true // and there is a valid ProjectInstanceId for the warning. - // if (_warningsAsErrorsByProject != null && warningEvent.BuildEventContext != null && warningEvent.BuildEventContext.ProjectInstanceId != BuildEventContext.InvalidProjectInstanceId) { // Attempt to get the list of warnings to treat as errors for the current project - // - if (_warningsAsErrorsByProject.TryGetValue(GetWarningsAsErrorOrMessageKey(warningEvent), out ISet codesByProject)) + int key = GetWarningsAsErrorOrMessageKey(warningEvent); + if (_warningsAsErrorsByProject.TryGetValue(key, out ISet codesByProject)) { // We create an empty set if all warnings should be treated as errors so that should be checked first. // If the set is not empty, check the specific code. - // - return codesByProject != null && (codesByProject.Count == 0 || codesByProject.Contains(warningEvent.Code)); + ISet codesToIgnoreByProject = null; + _warningsNotAsErrorsByProject?.TryGetValue(key, out codesToIgnoreByProject); + return codesByProject != null && + ((codesByProject.Count == 0 && (codesToIgnoreByProject is null || !codesToIgnoreByProject.Contains(warningEvent.Code))) + || codesByProject.Contains(warningEvent.Code)); } } diff --git a/src/Build/BackEnd/Components/Logging/TaskLoggingContext.cs b/src/Build/BackEnd/Components/Logging/TaskLoggingContext.cs index a6171cb4e91..5b8955d74b0 100644 --- a/src/Build/BackEnd/Components/Logging/TaskLoggingContext.cs +++ b/src/Build/BackEnd/Components/Logging/TaskLoggingContext.cs @@ -155,6 +155,11 @@ internal ICollection GetWarningsAsErrors() return LoggingService.GetWarningsAsErrors(BuildEventContext); } + internal ICollection GetWarningsNotAsErrors() + { + return LoggingService.GetWarningsNotAsErrors(BuildEventContext); + } + internal ICollection GetWarningsAsMessages() { return LoggingService.GetWarningsAsMessages(BuildEventContext); diff --git a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs index b8d7794cbef..288b872a54f 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/RequestBuilder.cs @@ -1304,19 +1304,16 @@ private void VerifyIsNotZombie() private void ConfigureWarningsAsErrorsAndMessages() { // Gather needed objects - // ProjectInstance project = _requestEntry?.RequestConfiguration?.Project; BuildEventContext buildEventContext = _projectLoggingContext?.BuildEventContext; ILoggingService loggingService = _projectLoggingContext?.LoggingService; // Ensure everything that is required is available at this time - // if (project != null && buildEventContext != null && loggingService != null && buildEventContext.ProjectInstanceId != BuildEventContext.InvalidProjectInstanceId) { if (String.Equals(project.GetPropertyValue(MSBuildConstants.TreatWarningsAsErrors)?.Trim(), "true", StringComparison.OrdinalIgnoreCase)) { // If signals the IEventSourceSink to treat all warnings as errors - // loggingService.AddWarningsAsErrors(buildEventContext, new HashSet()); } else @@ -1329,6 +1326,13 @@ private void ConfigureWarningsAsErrorsAndMessages() } } + ISet warningsNotAsErrors = ParseWarningCodes(project.GetPropertyValue(MSBuildConstants.WarningsNotAsErrors)); + + if (warningsNotAsErrors?.Count > 0) + { + loggingService.AddWarningsNotAsErrors(buildEventContext, warningsNotAsErrors); + } + ISet warningsAsMessages = ParseWarningCodes(project.GetPropertyValue(MSBuildConstants.WarningsAsMessages)); if (warningsAsMessages?.Count > 0) diff --git a/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs b/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs index fc7de19ac50..49f5a15b5ed 100644 --- a/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs +++ b/src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs @@ -713,6 +713,26 @@ private ICollection WarningsAsErrors } } + private ICollection _warningsNotAsErrors; + + /// + /// Contains all warnings that should be logged as errors. + /// Non-null empty set when all warnings should be treated as errors. + /// + private ICollection WarningsNotAsErrors + { + get + { + // Test compatibility + if (_taskLoggingContext == null) + { + return null; + } + + return _warningsNotAsErrors ??= _taskLoggingContext.GetWarningsNotAsErrors(); + } + } + private ICollection _warningsAsMessages; /// @@ -747,7 +767,12 @@ public bool ShouldTreatWarningAsError(string warningCode) } // An empty set means all warnings are errors. - return WarningsAsErrors.Count == 0 || WarningsAsErrors.Contains(warningCode); + return (WarningsAsErrors.Count == 0 && WarningAsErrorNotOverriden(warningCode)) || WarningsAsErrors.Contains(warningCode); + } + + private bool WarningAsErrorNotOverriden(string warningCode) + { + return WarningsNotAsErrors?.Contains(warningCode) != true; } #endregion diff --git a/src/Build/Instance/TaskFactories/TaskHostTask.cs b/src/Build/Instance/TaskFactories/TaskHostTask.cs index 4132f75aa57..e8d2bfb9ebd 100644 --- a/src/Build/Instance/TaskFactories/TaskHostTask.cs +++ b/src/Build/Instance/TaskFactories/TaskHostTask.cs @@ -274,6 +274,7 @@ public bool Execute() _setParameters, new Dictionary(_buildComponentHost.BuildParameters.GlobalProperties), _taskLoggingContext.GetWarningsAsErrors(), + _taskLoggingContext.GetWarningsNotAsErrors(), _taskLoggingContext.GetWarningsAsMessages() ); diff --git a/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt index e69de29bb2d..e99887c6db6 100644 --- a/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Build/PublicAPI/net/PublicAPI.Unshipped.txt @@ -0,0 +1,2 @@ +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 a0b76d9caa0..71d51dd24c8 100644 --- a/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Build/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -1,2 +1,4 @@ Microsoft.Build.Execution.BuildParameters.BuildThreadPriority.get -> System.Threading.ThreadPriority Microsoft.Build.Execution.BuildParameters.BuildThreadPriority.set -> void +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.get -> System.Collections.Generic.ISet +Microsoft.Build.Execution.BuildParameters.WarningsNotAsErrors.set -> void diff --git a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs index ccefc2aa252..9276e3dd9af 100644 --- a/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs +++ b/src/MSBuild.UnitTests/CommandLineSwitches_Tests.cs @@ -1012,6 +1012,7 @@ public void InvalidToolsVersionErrors() new StringWriter(), false, warningsAsErrors: null, + warningsNotAsErrors: null, warningsAsMessages: null, enableRestore: false, profilerLogger: null, diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 9339a10d18e..b83a04c54a2 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -2270,22 +2270,33 @@ public void BinaryLogContainsImportedFiles() archive.Entries.ShouldContain(e => e.FullName.EndsWith(".proj", StringComparison.OrdinalIgnoreCase), 2); } - [Fact] - public void EndToEndWarnAsErrors() - { - string projectContents = ObjectModelHelpers.CleanupFileContents(@" - + [Theory] + [InlineData("-warnaserror", "", "", false)] + [InlineData("-warnaserror -warnnotaserror:FOR123", "", "", true)] + [InlineData("-err: -warnnotaserror:FOR1234", "", "", false)] + [InlineData("-warnaserror", "", "FOR123", true)] + [InlineData("-warnaserror:FOR123", "", "FOR123", false)] + [InlineData("", "FOR123", "FOR123", false)] + [InlineData("", "", "FOR123", true)] + [InlineData("-warnaserror:FOR1234 -warnnotaserror:FOR123", "", "", false)] // The task should fire as a warning, but this should fail for having warnnotaserror used incorrectly. + public void EndToEndWarnAsErrors(string switches, string errorCodes, string notErrorCodes, bool expectedSuccess) + { + string projectContents = ObjectModelHelpers.CleanupFileContents(@$" + +{errorCodes} +{notErrorCodes} + - + "); TransientTestProjectWithFiles testProject = _env.CreateTestProjectWithFiles(projectContents); - RunnerUtilities.ExecMSBuild($"\"{testProject.ProjectFile}\" -warnaserror", out bool success, _output); + RunnerUtilities.ExecMSBuild($"\"{testProject.ProjectFile}\" {switches} ", out bool success, _output); - success.ShouldBeFalse(); + success.ShouldBe(expectedSuccess); } [Trait("Category", "netcore-osx-failing")] diff --git a/src/MSBuild/CommandLineSwitches.cs b/src/MSBuild/CommandLineSwitches.cs index d9bc14e1a6f..b086076c9f0 100644 --- a/src/MSBuild/CommandLineSwitches.cs +++ b/src/MSBuild/CommandLineSwitches.cs @@ -91,6 +91,7 @@ internal enum ParameterizedSwitch Preprocess, Targets, WarningsAsErrors, + WarningsNotAsErrors, WarningsAsMessages, BinaryLogger, Restore, @@ -257,6 +258,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", "noerr" }, ParameterizedSwitch.WarningsNotAsErrors, null, true, "MissingWarnNotAsErrorParameterError", true, false ), 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/OutOfProcTaskHostNode.cs b/src/MSBuild/OutOfProcTaskHostNode.cs index 6b54a4ec089..9ec5f525074 100644 --- a/src/MSBuild/OutOfProcTaskHostNode.cs +++ b/src/MSBuild/OutOfProcTaskHostNode.cs @@ -280,6 +280,8 @@ public bool IsRunningMultipleNodes /// private ICollection WarningsAsErrors { get; set; } + private ICollection WarningsNotAsErrors { get; set; } + private ICollection WarningsAsMessages { get; set; } public bool ShouldTreatWarningAsError(string warningCode) @@ -290,7 +292,12 @@ public bool ShouldTreatWarningAsError(string warningCode) return false; } - return WarningsAsErrors.Count == 0 || WarningsAsErrors.Contains(warningCode); + return (WarningsAsErrors.Count == 0 && WarningAsErrorNotOverriden(warningCode)) || WarningsAsMessages.Contains(warningCode); + } + + private bool WarningAsErrorNotOverriden(string warningCode) + { + return WarningsNotAsErrors?.Contains(warningCode) != true; } #endregion @@ -868,6 +875,7 @@ private void RunTask(object state) _updateEnvironment = !taskConfiguration.BuildProcessEnvironment.ContainsValueAndIsEqual("MSBuildTaskHostDoNotUpdateEnvironment", "1", StringComparison.OrdinalIgnoreCase); _updateEnvironmentAndLog = taskConfiguration.BuildProcessEnvironment.ContainsValueAndIsEqual("MSBuildTaskHostUpdateEnvironmentAndLog", "1", StringComparison.OrdinalIgnoreCase); WarningsAsErrors = taskConfiguration.WarningsAsErrors; + WarningsNotAsErrors = taskConfiguration.WarningsNotAsErrors; WarningsAsMessages = taskConfiguration.WarningsAsMessages; try { diff --git a/src/MSBuild/Resources/Strings.resx b/src/MSBuild/Resources/Strings.resx index 61b9471ba63..5698a15c31a 100644 --- a/src/MSBuild/Resources/Strings.resx +++ b/src/MSBuild/Resources/Strings.resx @@ -824,6 +824,22 @@ Copyright (C) Microsoft Corporation. All rights reserved. LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + MSBUILD : Configuration error MSB1043: The application could not start. {0} @@ -1258,6 +1274,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 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} @@ -1290,11 +1314,15 @@ Copyright (C) Microsoft Corporation. All rights reserved. MSBuild version = "{0}" + + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. diff --git a/src/MSBuild/Resources/xlf/Strings.cs.xlf b/src/MSBuild/Resources/xlf/Strings.cs.xlf index 3391a53a640..f4594df081d 100644 --- a/src/MSBuild/Resources/xlf/Strings.cs.xlf +++ b/src/MSBuild/Resources/xlf/Strings.cs.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. Všechna práva vyhrazena. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1211,6 +1237,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1221,6 +1256,11 @@ Copyright (C) Microsoft Corporation. Všechna práva vyhrazena. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Zadaný protokolovací nástroj nebylo možné vytvořit a nebude se používat. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.de.xlf b/src/MSBuild/Resources/xlf/Strings.de.xlf index 63493f136ce..c3190aa3e82 100644 --- a/src/MSBuild/Resources/xlf/Strings.de.xlf +++ b/src/MSBuild/Resources/xlf/Strings.de.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Die angegebene Protokollierung konnte nicht erstellt werden und wird nicht verwendet. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.es.xlf b/src/MSBuild/Resources/xlf/Strings.es.xlf index 956059968ba..00c20831591 100644 --- a/src/MSBuild/Resources/xlf/Strings.es.xlf +++ b/src/MSBuild/Resources/xlf/Strings.es.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. Todos los derechos reservados. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1212,6 +1238,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1222,6 +1257,11 @@ Copyright (C) Microsoft Corporation. Todos los derechos reservados. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} No se pudo crear el registrador especificado y no se usará. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.fr.xlf b/src/MSBuild/Resources/xlf/Strings.fr.xlf index a0aa66f7a84..fc583113035 100644 --- a/src/MSBuild/Resources/xlf/Strings.fr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.fr.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. Tous droits réservés. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation. Tous droits réservés. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Le journaliseur spécifié n'a pas pu être créé et ne sera pas utilisé. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.it.xlf b/src/MSBuild/Resources/xlf/Strings.it.xlf index 200a7a77dae..e04fdf43c75 100644 --- a/src/MSBuild/Resources/xlf/Strings.it.xlf +++ b/src/MSBuild/Resources/xlf/Strings.it.xlf @@ -255,6 +255,32 @@ Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1225,6 +1251,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1235,6 +1270,11 @@ Copyright (C) Microsoft Corporation. Tutti i diritti sono riservati. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Non è stato possibile creare il logger specificato, che quindi non verrà usato. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.ja.xlf b/src/MSBuild/Resources/xlf/Strings.ja.xlf index 453bbc44766..a3728c614ea 100644 --- a/src/MSBuild/Resources/xlf/Strings.ja.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ja.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation.All rights reserved. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation.All rights reserved. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} 指定されたロガーを作成できなかったため、使用されません。{0} diff --git a/src/MSBuild/Resources/xlf/Strings.ko.xlf b/src/MSBuild/Resources/xlf/Strings.ko.xlf index e57ed62661a..ff550586d85 100644 --- a/src/MSBuild/Resources/xlf/Strings.ko.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ko.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. All rights reserved. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation. All rights reserved. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} 지정된 로거를 만들 수 없어 지정된 로거가 사용되지 않습니다. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.pl.xlf b/src/MSBuild/Resources/xlf/Strings.pl.xlf index c1e63e21afe..cf106b7b147 100644 --- a/src/MSBuild/Resources/xlf/Strings.pl.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pl.xlf @@ -255,6 +255,32 @@ Copyright (C) Microsoft Corporation. Wszelkie prawa zastrzeżone. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1217,6 +1243,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1227,6 +1262,11 @@ Copyright (C) Microsoft Corporation. Wszelkie prawa zastrzeżone. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Nie można utworzyć określonego rejestratora i nie zostanie on użyty. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf index e8293005192..7e785f78d94 100644 --- a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf @@ -249,6 +249,32 @@ isoladamente. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1204,6 +1230,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1214,6 +1249,11 @@ isoladamente. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Não foi possível criar o agente especificado e ele não será usado. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.ru.xlf b/src/MSBuild/Resources/xlf/Strings.ru.xlf index d5f02251680..37466ac1145 100644 --- a/src/MSBuild/Resources/xlf/Strings.ru.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ru.xlf @@ -247,6 +247,32 @@ Copyright (C) Microsoft Corporation. All rights reserved. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1202,6 +1228,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1212,6 +1247,11 @@ Copyright (C) Microsoft Corporation. All rights reserved. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Указанное средство ведения журнала не может быть создано и не будет использоваться. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.tr.xlf b/src/MSBuild/Resources/xlf/Strings.tr.xlf index 06ed57c5523..799afba2430 100644 --- a/src/MSBuild/Resources/xlf/Strings.tr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.tr.xlf @@ -248,6 +248,32 @@ Telif Hakkı (C) Microsoft Corporation. Tüm hakları saklıdır. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1207,6 +1233,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1217,6 +1252,11 @@ Telif Hakkı (C) Microsoft Corporation. Tüm hakları saklıdır. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} Belirtilen günlükçü oluşturulamadığından kullanılamıyor. {0} diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf index 3a68a4c3a6b..db90f28f641 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. All rights reserved. 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation. All rights reserved. LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} 无法创建指定的记录器,将不会使用它。{0} diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf index 5992ad480da..b08f153da1b 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf @@ -248,6 +248,32 @@ Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。 3) all switch names and their short forms e.g. -property, or -p 4) all verbosity levels and their short forms e.g. quiet, or q LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. + + + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + -warnNotAsError[:code[;code2]] + List of warning codes to treats not treat as errors. + Use a semicolon or a comma to separate + multiple warning codes. Has no effect if the -warnaserror + switch is not set. + + Example: + -warnNotAsError:MSB3026 + + + LOCALIZATION: "-warnNotAsError" should not be localized. + LOCALIZATION: None of the lines should be longer than a standard width console window, eg 80 chars. @@ -1203,6 +1229,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 when using the -warnNotAsError switch. + MSBUILD : error MSB1060: Specify one or more warning codes 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. @@ -1213,6 +1248,11 @@ Copyright (C) Microsoft Corporation. 著作權所有,並保留一切權利。 LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:" should not be localized. + + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + MSBUILD : error MSB1062: The -warnnotaserror switch cannot be specified unless the -warnaserror switch is also specified and left empty. + {StrBegin="MSBUILD : error MSB1062: "}LOCALIZATION: The prefix "MSBUILD : error MSBxxxx:", "-warnnotaserror" and "-warnaserror" should not be localized. + The specified logger could not be created and will not be used. {0} 無法建立指定的記錄器,且不會使用。{0} diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index e28ca074553..125086ead48 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -552,6 +552,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; @@ -585,6 +586,7 @@ string[] commandLine ref targetsWriter, ref detailedSummary, ref warningsAsErrors, + ref warningsNotAsErrors, ref warningsAsMessages, ref enableRestore, ref interactive, @@ -654,27 +656,27 @@ string[] commandLine #if FEATURE_XML_SCHEMA_VALIDATION needToValidateProject, schemaFile, #endif - cpuCount, - enableNodeReuse, - preprocessWriter, - targetsWriter, - detailedSummary, - warningsAsErrors, - warningsAsMessages, - enableRestore, - profilerLogger, - enableProfiler, - interactive, - isolateProjects, - graphBuildOptions, - lowPriority, - inputResultsCaches, - outputResultsCache, - commandLine - )) - { - exitType = ExitType.BuildError; - } + cpuCount, + enableNodeReuse, + preprocessWriter, + targetsWriter, + detailedSummary, + warningsAsErrors, + warningsNotAsErrors, + warningsAsMessages, + enableRestore, + profilerLogger, + enableProfiler, + interactive, + isolateProjects, + graphBuildOptions, + lowPriority, + inputResultsCaches, + outputResultsCache, + commandLine)) + { + exitType = ExitType.BuildError; + } } // end of build DateTime t2 = DateTime.Now; @@ -953,6 +955,7 @@ internal static bool BuildProject TextWriter targetsWriter, bool detailedSummary, ISet warningsAsErrors, + ISet warningsNotAsErrors, ISet warningsAsMessages, bool enableRestore, ProfilerLogger profilerLogger, @@ -1129,6 +1132,7 @@ string[] commandLine parameters.DetailedSummary = detailedSummary; parameters.LogTaskInputs = logTaskInputs; parameters.WarningsAsErrors = warningsAsErrors; + parameters.WarningsNotAsErrors = warningsNotAsErrors; parameters.WarningsAsMessages = warningsAsMessages; parameters.Interactive = interactive; parameters.IsolateProjects = isolateProjects; @@ -1986,6 +1990,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, @@ -2103,6 +2108,7 @@ bool recursing ref targetsWriter, ref detailedSummary, ref warningsAsErrors, + ref warningsNotAsErrors, ref warningsAsMessages, ref enableRestore, ref interactive, @@ -2154,6 +2160,8 @@ bool recursing warningsAsErrors = ProcessWarnAsErrorSwitch(commandLineSwitches); + warningsNotAsErrors = ProcessWarnNotAsErrorSwitch(commandLineSwitches); + warningsAsMessages = ProcessWarnAsMessageSwitch(commandLineSwitches); if (commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.Restore)) @@ -2237,6 +2245,14 @@ out enableProfiler schemaFile = ProcessValidateSwitch(commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.Validate]); #endif invokeBuild = true; + + if (commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.WarningsNotAsErrors) && + !WarningsAsErrorsSwitchIsEmpty(commandLineSwitches)!) + { + commandLineSwitches.SetSwitchError("NotWarnAsErrorWithoutWarnAsError", + commandLineSwitches.GetParameterizedSwitchCommandLineArg(CommandLineSwitches.ParameterizedSwitch.WarningsNotAsErrors)); + commandLineSwitches.ThrowErrors(); + } } } @@ -2245,6 +2261,18 @@ out enableProfiler return invokeBuild; } + private static bool WarningsAsErrorsSwitchIsEmpty(CommandLineSwitches commandLineSwitches) + { + string val = commandLineSwitches.GetParameterizedSwitchCommandLineArg(CommandLineSwitches.ParameterizedSwitch.WarningsAsErrors); + if (val is null) + { + return false; + } + + int indexOfColon = val.IndexOf(":"); + return indexOfColon < 0 || indexOfColon == val.Length - 1; + } + internal static GraphBuildOptions ProcessGraphBuildSwitch(string[] parameters) { var options = new GraphBuildOptions(); @@ -2376,18 +2404,16 @@ 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 })) @@ -2396,37 +2422,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) @@ -3625,6 +3644,7 @@ private static void ShowHelpMessage() Console.WriteLine(AssemblyResources.GetString("HelpMessage_11_LoggerSwitch")); Console.WriteLine(AssemblyResources.GetString("HelpMessage_30_BinaryLoggerSwitch")); Console.WriteLine(AssemblyResources.GetString("HelpMessage_28_WarnAsErrorSwitch")); + Console.WriteLine(AssemblyResources.GetString("HelpMessage_40_WarnNotAsErrorSwitch")); Console.WriteLine(AssemblyResources.GetString("HelpMessage_29_WarnAsMessageSwitch")); #if FEATURE_XML_SCHEMA_VALIDATION Console.WriteLine(AssemblyResources.GetString("HelpMessage_15_ValidateSwitch")); diff --git a/src/Shared/Constants.cs b/src/Shared/Constants.cs index 3f63bd381c6..4a59448c172 100644 --- a/src/Shared/Constants.cs +++ b/src/Shared/Constants.cs @@ -38,6 +38,11 @@ internal static class MSBuildConstants /// internal const string WarningsAsErrors = "MSBuildWarningsAsErrors"; + /// + /// Name of the property that indicates a list of warnings to not treat as errors. + /// + internal const string WarningsNotAsErrors = "MSBuildWarningsNotAsErrors"; + /// /// Name of the property that indicates the list of warnings to treat as messages. /// diff --git a/src/Shared/TaskHostConfiguration.cs b/src/Shared/TaskHostConfiguration.cs index 7b0c1f9dbef..7037787b2fe 100644 --- a/src/Shared/TaskHostConfiguration.cs +++ b/src/Shared/TaskHostConfiguration.cs @@ -93,6 +93,7 @@ internal class TaskHostConfiguration : INodePacket private Dictionary _globalParameters; private ICollection _warningsAsErrors; + private ICollection _warningsNotAsErrors; private ICollection _warningsAsMessages; @@ -116,6 +117,7 @@ internal class TaskHostConfiguration : INodePacket /// Parameters to apply to the task. /// global properties for the current project. /// Warning codes to be treated as errors for the current project. + /// Warning codes not to be treated as errors for the current project. /// Warning codes to be treated as messages for the current project. #else /// @@ -136,6 +138,7 @@ internal class TaskHostConfiguration : INodePacket /// Parameters to apply to the task. /// global properties for the current project. /// Warning codes to be logged as errors for the current project. + /// Warning codes not to be treated as errors for the current project. /// Warning codes to be treated as messages for the current project. #endif public TaskHostConfiguration @@ -158,6 +161,7 @@ public TaskHostConfiguration IDictionary taskParameters, Dictionary globalParameters, ICollection warningsAsErrors, + ICollection warningsNotAsErrors, ICollection warningsAsMessages ) { @@ -190,6 +194,7 @@ ICollection warningsAsMessages _taskLocation = taskLocation; _isTaskInputLoggingEnabled = isTaskInputLoggingEnabled; _warningsAsErrors = warningsAsErrors; + _warningsNotAsErrors = warningsNotAsErrors; _warningsAsMessages = warningsAsMessages; if (taskParameters != null) @@ -384,6 +389,15 @@ public ICollection WarningsAsErrors } } + public ICollection WarningsNotAsErrors + { + [DebuggerStepThrough] + get + { + return _warningsNotAsErrors; + } + } + public ICollection WarningsAsMessages { [DebuggerStepThrough] @@ -422,6 +436,13 @@ public void Translate(ITranslator translator) collectionFactory: count => new HashSet(StringComparer.OrdinalIgnoreCase)); #else collectionFactory: count => new HashSet(count, StringComparer.OrdinalIgnoreCase)); +#endif + translator.Translate(collection: ref _warningsNotAsErrors, + objectTranslator: (ITranslator t, ref string s) => t.Translate(ref s), +#if CLR2COMPATIBILITY + collectionFactory: count => new HashSet(StringComparer.OrdinalIgnoreCase)); +#else + collectionFactory: count => new HashSet(count, StringComparer.OrdinalIgnoreCase)); #endif translator.Translate(collection: ref _warningsAsMessages, objectTranslator: (ITranslator t, ref string s) => t.Translate(ref s),