Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/MSBuild.UnitTests/XMake_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,23 @@ public void ResponseFileInProjectDirectoryWithSolutionProjectDifferentNamesShoul
successfulExit.ShouldBeTrue();
}

[Fact]
public void ResponseFileNoticeIsPrintedOnSwitchError()
{
var directory = _env.CreateFolder();
var content = ObjectModelHelpers.CleanupFileContents("<Project><Target Name='t'><Message Text='Completed'/></Target></Project>");
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");
}
Comment thread
AlesProkop marked this conversation as resolved.

/// <summary>
/// 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.
Expand Down
16 changes: 16 additions & 0 deletions src/MSBuild/XMake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
}
Comment thread
AlesProkop marked this conversation as resolved.
}

/// <summary>
/// Displays the build engine's version number.
/// </summary>
Expand Down