From 0fa001ab01fbfbc83a77c3c770e5a5705b9e6f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Prokop?= Date: Mon, 4 May 2026 11:02:56 +0200 Subject: [PATCH 1/4] [Draft] warning before error --- src/MSBuild.UnitTests/XMake_Tests.cs | 17 +++++++++++++++++ src/MSBuild/XMake.cs | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 9ba8009acbd..b0429cd937e 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -1571,6 +1571,23 @@ public void ResponseFileInProjectDirectoryWithSolutionProjectDifferentNamesShoul successfulExit.ShouldBeTrue(); } + [Fact] + public void ResponseFileNoticeIsPrintedOnSwitchError() + { + var directory = _env.CreateFolder(); + var content = ObjectModelHelpers.CleanupFileContents(""); + directory.CreateFile("foo.proj", content); + var projectPath = directory.CreateFile("bar.proj", content).Path; + var rspPath = directory.CreateFile("Directory.Build.rsp", "foo.proj").Path; + + string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\"", out var successfulExit, _output); + + successfulExit.ShouldBeFalse(); + output.ShouldContain("Some command line switches were read from the auto-response file"); + output.ShouldContain(rspPath); + output.ShouldContain("MSB1008"); + } + /// /// Any msbuild.rsp in the directory of the specified project/solution should be read, and should /// take priority over any other response files. Sanity test when there isn't one. diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index a55f9f1c295..58e5888db10 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -937,6 +937,11 @@ public static ExitType Execute(string[] commandLine) // handle switch errors catch (CommandLineSwitchException e) { + if (commandLineParser.IncludedResponseFiles.Count > 0) + { + PrintResponseFileNotices(); + } + Console.WriteLine(e.Message); Console.WriteLine(); // prompt user to display help for proper switch usage @@ -4209,6 +4214,17 @@ private static void ShowHelpPrompt() Console.WriteLine(AssemblyResources.GetString("HelpPrompt")); } + private static void PrintResponseFileNotices() + { + foreach (string responseFilePath in commandLineParser.IncludedResponseFiles) + { + Console.WriteLine( + ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( + "PickedUpSwitchesFromAutoResponse", + responseFilePath)); + } + } + /// /// Displays the build engine's version number. /// From 93c7d2283c6fbfa7a18b76587e079e99e7998075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Prokop?= Date: Mon, 4 May 2026 13:40:18 +0200 Subject: [PATCH 2/4] adressed copilot comments --- src/MSBuild.UnitTests/XMake_Tests.cs | 23 +++++++++++++++++++- src/MSBuild/CommandLine/CommandLineParser.cs | 9 ++++++++ src/MSBuild/XMake.cs | 8 +++---- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index b0429cd937e..15ff48e15b1 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -1574,6 +1574,7 @@ public void ResponseFileInProjectDirectoryWithSolutionProjectDifferentNamesShoul [Fact] public void ResponseFileNoticeIsPrintedOnSwitchError() { + _env.SetEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US"); var directory = _env.CreateFolder(); var content = ObjectModelHelpers.CleanupFileContents(""); directory.CreateFile("foo.proj", content); @@ -1583,8 +1584,28 @@ public void ResponseFileNoticeIsPrintedOnSwitchError() string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\"", out var successfulExit, _output); successfulExit.ShouldBeFalse(); - output.ShouldContain("Some command line switches were read from the auto-response file"); + int noticeIndex = output.IndexOf("Some command line switches were read from the auto-response file", StringComparison.OrdinalIgnoreCase); + int errorIndex = output.IndexOf("MSB1008", StringComparison.OrdinalIgnoreCase); + noticeIndex.ShouldBeGreaterThanOrEqualTo(0); + errorIndex.ShouldBeGreaterThanOrEqualTo(0); + noticeIndex.ShouldBeLessThan(errorIndex); output.ShouldContain(rspPath); + } + + [Fact] + public void ExplicitResponseFileNoticeIsNotPrintedOnSwitchError() + { + _env.SetEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US"); + var directory = _env.CreateFolder(); + var content = ObjectModelHelpers.CleanupFileContents(""); + directory.CreateFile("foo.proj", content); + var projectPath = directory.CreateFile("bar.proj", content).Path; + var rspPath = directory.CreateFile("explicit.rsp", "foo.proj").Path; + + string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\" @\"{rspPath}\" -noAutoResponse", out var successfulExit, _output); + + successfulExit.ShouldBeFalse(); + output.ShouldNotContain("Some command line switches were read from the auto-response file"); output.ShouldContain("MSB1008"); } diff --git a/src/MSBuild/CommandLine/CommandLineParser.cs b/src/MSBuild/CommandLine/CommandLineParser.cs index 59512cec8e8..72c15b7b274 100644 --- a/src/MSBuild/CommandLine/CommandLineParser.cs +++ b/src/MSBuild/CommandLine/CommandLineParser.cs @@ -46,6 +46,13 @@ internal class CommandLineParser internal IReadOnlyList IncludedResponseFiles => includedResponseFiles ?? (IReadOnlyList)Array.Empty(); + /// + /// Used to keep track of response files automatically discovered by MSBuild. + /// + private List autoResponseFiles; + + internal IReadOnlyList AutoResponseFiles => autoResponseFiles ?? (IReadOnlyList)Array.Empty(); + /// /// Parses the provided command-line arguments into a . /// @@ -666,6 +673,7 @@ private bool GatherAutoResponseFileSwitchesFromFullPath(string autoResponseFile, { found = true; GatherResponseFileSwitch($"@{autoResponseFile}", switchesFromAutoResponseFile, commandLine); + autoResponseFiles.Add(Path.GetFullPath(autoResponseFile)); // if the "/noautoresponse" switch was set in the auto-response file, flag an error if (switchesFromAutoResponseFile[CommandLineSwitches.ParameterlessSwitch.NoAutoResponse]) @@ -724,6 +732,7 @@ internal static int GetLengthOfSwitchIndicator(string unquotedSwitch) public void ResetGatheringSwitchesState() { includedResponseFiles = new List(); + autoResponseFiles = new List(); CommandLineSwitches.SwitchesFromResponseFiles = new(); } } diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 58e5888db10..262e08a0124 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -937,9 +937,9 @@ public static ExitType Execute(string[] commandLine) // handle switch errors catch (CommandLineSwitchException e) { - if (commandLineParser.IncludedResponseFiles.Count > 0) + if (commandLineParser.AutoResponseFiles.Count > 0) { - PrintResponseFileNotices(); + PrintAutoResponseFileNotices(); } Console.WriteLine(e.Message); @@ -4214,9 +4214,9 @@ private static void ShowHelpPrompt() Console.WriteLine(AssemblyResources.GetString("HelpPrompt")); } - private static void PrintResponseFileNotices() + private static void PrintAutoResponseFileNotices() { - foreach (string responseFilePath in commandLineParser.IncludedResponseFiles) + foreach (string responseFilePath in commandLineParser.AutoResponseFiles) { Console.WriteLine( ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( From dd3c8a5204e133f1b10618b08a08dd5ebd8ef5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Prokop?= Date: Thu, 14 May 2026 16:27:19 +0200 Subject: [PATCH 3/4] addressed comments --- src/MSBuild.UnitTests/XMake_Tests.cs | 12 ++++++++---- src/MSBuild/CommandLine/CommandLineParser.cs | 9 --------- src/MSBuild/Resources/Strings.resx | 14 ++++++++++++++ src/MSBuild/Resources/xlf/Strings.cs.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.de.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.es.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.fr.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.it.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.ja.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.ko.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.pl.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.pt-BR.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.ru.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.tr.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.xlf | 16 +++++++++++++++- src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf | 16 ++++++++++++++++ src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf | 16 ++++++++++++++++ src/MSBuild/XMake.cs | 19 +++++++++++-------- 18 files changed, 256 insertions(+), 22 deletions(-) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 15ff48e15b1..9332aa78329 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -1584,7 +1584,7 @@ public void ResponseFileNoticeIsPrintedOnSwitchError() string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\"", out var successfulExit, _output); successfulExit.ShouldBeFalse(); - int noticeIndex = output.IndexOf("Some command line switches were read from the auto-response file", StringComparison.OrdinalIgnoreCase); + int noticeIndex = output.IndexOf("Some command line switches were read from this response file", StringComparison.OrdinalIgnoreCase); int errorIndex = output.IndexOf("MSB1008", StringComparison.OrdinalIgnoreCase); noticeIndex.ShouldBeGreaterThanOrEqualTo(0); errorIndex.ShouldBeGreaterThanOrEqualTo(0); @@ -1593,7 +1593,7 @@ public void ResponseFileNoticeIsPrintedOnSwitchError() } [Fact] - public void ExplicitResponseFileNoticeIsNotPrintedOnSwitchError() + public void ExplicitResponseFileNoticeIsPrintedOnSwitchError() { _env.SetEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US"); var directory = _env.CreateFolder(); @@ -1605,8 +1605,12 @@ public void ExplicitResponseFileNoticeIsNotPrintedOnSwitchError() string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\" @\"{rspPath}\" -noAutoResponse", out var successfulExit, _output); successfulExit.ShouldBeFalse(); - output.ShouldNotContain("Some command line switches were read from the auto-response file"); - output.ShouldContain("MSB1008"); + int noticeIndex = output.IndexOf("Some command line switches were read from this response file", StringComparison.OrdinalIgnoreCase); + int errorIndex = output.IndexOf("MSB1008", StringComparison.OrdinalIgnoreCase); + noticeIndex.ShouldBeGreaterThanOrEqualTo(0); + errorIndex.ShouldBeGreaterThanOrEqualTo(0); + noticeIndex.ShouldBeLessThan(errorIndex); + output.ShouldContain(rspPath); } /// diff --git a/src/MSBuild/CommandLine/CommandLineParser.cs b/src/MSBuild/CommandLine/CommandLineParser.cs index 72c15b7b274..59512cec8e8 100644 --- a/src/MSBuild/CommandLine/CommandLineParser.cs +++ b/src/MSBuild/CommandLine/CommandLineParser.cs @@ -46,13 +46,6 @@ internal class CommandLineParser internal IReadOnlyList IncludedResponseFiles => includedResponseFiles ?? (IReadOnlyList)Array.Empty(); - /// - /// Used to keep track of response files automatically discovered by MSBuild. - /// - private List autoResponseFiles; - - internal IReadOnlyList AutoResponseFiles => autoResponseFiles ?? (IReadOnlyList)Array.Empty(); - /// /// Parses the provided command-line arguments into a . /// @@ -673,7 +666,6 @@ private bool GatherAutoResponseFileSwitchesFromFullPath(string autoResponseFile, { found = true; GatherResponseFileSwitch($"@{autoResponseFile}", switchesFromAutoResponseFile, commandLine); - autoResponseFiles.Add(Path.GetFullPath(autoResponseFile)); // if the "/noautoresponse" switch was set in the auto-response file, flag an error if (switchesFromAutoResponseFile[CommandLineSwitches.ParameterlessSwitch.NoAutoResponse]) @@ -732,7 +724,6 @@ internal static int GetLengthOfSwitchIndicator(string unquotedSwitch) public void ResetGatheringSwitchesState() { includedResponseFiles = new List(); - autoResponseFiles = new List(); CommandLineSwitches.SwitchesFromResponseFiles = new(); } } diff --git a/src/MSBuild/Resources/Strings.resx b/src/MSBuild/Resources/Strings.resx index b2e5738fac1..b7059149adc 100644 --- a/src/MSBuild/Resources/Strings.resx +++ b/src/MSBuild/Resources/Strings.resx @@ -1321,6 +1321,20 @@ where the switches are coming from. + + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. + + MSBUILD : error MSB1009: Project file does not exist. {StrBegin="MSBUILD : error MSB1009: "}UE: This message does not need in-line parameters because the exception takes care of displaying the invalid arg. diff --git a/src/MSBuild/Resources/xlf/Strings.cs.xlf b/src/MSBuild/Resources/xlf/Strings.cs.xlf index b2b3beb0547..b8e52d30c20 100644 --- a/src/MSBuild/Resources/xlf/Strings.cs.xlf +++ b/src/MSBuild/Resources/xlf/Strings.cs.xlf @@ -1729,6 +1729,22 @@ Když se nastaví na MessageUponIsolationViolation (nebo jeho krátký UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.de.xlf b/src/MSBuild/Resources/xlf/Strings.de.xlf index d7d66ea6ca4..5c5f27e6856 100644 --- a/src/MSBuild/Resources/xlf/Strings.de.xlf +++ b/src/MSBuild/Resources/xlf/Strings.de.xlf @@ -1717,6 +1717,22 @@ Hinweis: Ausführlichkeit der Dateiprotokollierungen UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.es.xlf b/src/MSBuild/Resources/xlf/Strings.es.xlf index 64ed64c1c79..3c2d02cf70c 100644 --- a/src/MSBuild/Resources/xlf/Strings.es.xlf +++ b/src/MSBuild/Resources/xlf/Strings.es.xlf @@ -1723,6 +1723,22 @@ Esta marca es experimental y puede que no funcione según lo previsto. UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.fr.xlf b/src/MSBuild/Resources/xlf/Strings.fr.xlf index 58ba63c329c..39e03f2f81b 100644 --- a/src/MSBuild/Resources/xlf/Strings.fr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.fr.xlf @@ -1717,6 +1717,22 @@ Remarque : verbosité des enregistreurs d’événements de fichiers UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.it.xlf b/src/MSBuild/Resources/xlf/Strings.it.xlf index 1ea94c50c0a..a57d76b6afa 100644 --- a/src/MSBuild/Resources/xlf/Strings.it.xlf +++ b/src/MSBuild/Resources/xlf/Strings.it.xlf @@ -1727,6 +1727,22 @@ Nota: livello di dettaglio dei logger di file UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.ja.xlf b/src/MSBuild/Resources/xlf/Strings.ja.xlf index f9c088f287a..b37468acb7f 100644 --- a/src/MSBuild/Resources/xlf/Strings.ja.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ja.xlf @@ -1717,6 +1717,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.ko.xlf b/src/MSBuild/Resources/xlf/Strings.ko.xlf index 163e4fa6a48..0af95c43e99 100644 --- a/src/MSBuild/Resources/xlf/Strings.ko.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ko.xlf @@ -1718,6 +1718,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.pl.xlf b/src/MSBuild/Resources/xlf/Strings.pl.xlf index 05d8a97eb6f..ff598d3eb5a 100644 --- a/src/MSBuild/Resources/xlf/Strings.pl.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pl.xlf @@ -1726,6 +1726,22 @@ Ta flaga jest eksperymentalna i może nie działać zgodnie z oczekiwaniami. UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf index 88b2c006c88..3d2131cd6bc 100644 --- a/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf +++ b/src/MSBuild/Resources/xlf/Strings.pt-BR.xlf @@ -1717,6 +1717,22 @@ arquivo de resposta. UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.ru.xlf b/src/MSBuild/Resources/xlf/Strings.ru.xlf index 76f95202e52..a0170030738 100644 --- a/src/MSBuild/Resources/xlf/Strings.ru.xlf +++ b/src/MSBuild/Resources/xlf/Strings.ru.xlf @@ -1715,6 +1715,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.tr.xlf b/src/MSBuild/Resources/xlf/Strings.tr.xlf index 9f477ca8464..4698e58ecf8 100644 --- a/src/MSBuild/Resources/xlf/Strings.tr.xlf +++ b/src/MSBuild/Resources/xlf/Strings.tr.xlf @@ -1720,6 +1720,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.xlf b/src/MSBuild/Resources/xlf/Strings.xlf index a16ca1ca45e..83310407b84 100644 --- a/src/MSBuild/Resources/xlf/Strings.xlf +++ b/src/MSBuild/Resources/xlf/Strings.xlf @@ -717,6 +717,20 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. @@ -1056,4 +1070,4 @@ - \ No newline at end of file + diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf index b76b30b3932..28c4992c157 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf @@ -1717,6 +1717,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf index ceeaa6b7686..98dec8ffcc6 100644 --- a/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf +++ b/src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf @@ -1717,6 +1717,22 @@ UE: This message appears in high verbosity modes when we used some switches from the auto-response file msbuild.rsp: otherwise the user may be unaware where the switches are coming from. + + + + Some command line switches were read from this response file: + Some command line switches were read from this response file: + + UE: This message appears before a command-line parsing error when switches were read from a response file: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file path is printed on a separate line after this message. + + + + Some command line switches were read from these response files: + Some command line switches were read from these response files: + + UE: This message appears before a command-line parsing error when switches were read from response files: otherwise the user may be unaware where the switches are coming from. + LOCALIZATION: The response file paths are printed on separate lines after this message. diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 262e08a0124..f8102560e78 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -937,9 +937,9 @@ public static ExitType Execute(string[] commandLine) // handle switch errors catch (CommandLineSwitchException e) { - if (commandLineParser.AutoResponseFiles.Count > 0) + if (commandLineParser.IncludedResponseFiles.Count > 0) { - PrintAutoResponseFileNotices(); + PrintResponseFileNotices(); } Console.WriteLine(e.Message); @@ -4214,14 +4214,17 @@ private static void ShowHelpPrompt() Console.WriteLine(AssemblyResources.GetString("HelpPrompt")); } - private static void PrintAutoResponseFileNotices() + private static void PrintResponseFileNotices() { - foreach (string responseFilePath in commandLineParser.AutoResponseFiles) + Console.WriteLine( + AssemblyResources.GetString( + commandLineParser.IncludedResponseFiles.Count == 1 + ? "PickedUpSwitchesFromResponseFile" + : "PickedUpSwitchesFromResponseFiles")); + + foreach (string responseFilePath in commandLineParser.IncludedResponseFiles) { - Console.WriteLine( - ResourceUtilities.FormatResourceStringIgnoreCodeAndKeyword( - "PickedUpSwitchesFromAutoResponse", - responseFilePath)); + Console.WriteLine($" {responseFilePath}"); } } From 8c9c07ea7223a8289ddc48b7290ef17d45c9ff56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Prokop?= Date: Fri, 15 May 2026 08:43:31 +0200 Subject: [PATCH 4/4] fixed unit test --- src/MSBuild.UnitTests/XMake_Tests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/MSBuild.UnitTests/XMake_Tests.cs b/src/MSBuild.UnitTests/XMake_Tests.cs index 9332aa78329..74abd567c5f 100644 --- a/src/MSBuild.UnitTests/XMake_Tests.cs +++ b/src/MSBuild.UnitTests/XMake_Tests.cs @@ -1584,7 +1584,7 @@ public void ResponseFileNoticeIsPrintedOnSwitchError() string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\"", out var successfulExit, _output); successfulExit.ShouldBeFalse(); - int noticeIndex = output.IndexOf("Some command line switches were read from this response file", StringComparison.OrdinalIgnoreCase); + int noticeIndex = output.IndexOf("Some command line switches were read from", StringComparison.OrdinalIgnoreCase); int errorIndex = output.IndexOf("MSB1008", StringComparison.OrdinalIgnoreCase); noticeIndex.ShouldBeGreaterThanOrEqualTo(0); errorIndex.ShouldBeGreaterThanOrEqualTo(0); @@ -1605,7 +1605,7 @@ public void ExplicitResponseFileNoticeIsPrintedOnSwitchError() string output = RunnerUtilities.ExecMSBuild($"\"{projectPath}\" @\"{rspPath}\" -noAutoResponse", out var successfulExit, _output); successfulExit.ShouldBeFalse(); - int noticeIndex = output.IndexOf("Some command line switches were read from this response file", StringComparison.OrdinalIgnoreCase); + int noticeIndex = output.IndexOf("Some command line switches were read from", StringComparison.OrdinalIgnoreCase); int errorIndex = output.IndexOf("MSB1008", StringComparison.OrdinalIgnoreCase); noticeIndex.ShouldBeGreaterThanOrEqualTo(0); errorIndex.ShouldBeGreaterThanOrEqualTo(0);