Skip to content

Commit 691c464

Browse files
baronfelCopilotmarcpopMSFTCopilot
authored
[release/10.0.3xx] Fix dotnet tool runner stripping duplicate flags when rollForward is enabled (#53821)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com> Co-authored-by: Marc Paine <marcpop@microsoft.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2 parents c840dab + dd2b76a commit 691c464

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/Cli/dotnet/CommandFactory/CommandResolution/MuxerCommandSpecMaker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal static CommandSpec CreatePackageCommandSpecUsingMuxer(
3838
{
3939
if (rollForwardArgument.Any())
4040
{
41-
arguments.AddRange(commandArguments.Except(rollForwardArgument));
41+
arguments.AddRange(commandArguments.Where(arg => !arg.Equals("--allow-roll-forward", StringComparison.OrdinalIgnoreCase)));
4242
}
4343
else
4444
{

test/dotnet.Tests/CommandTests/Tool/Run/ToolRunCommandTests.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ public void WhenRunWithRollForwardOptionItShouldIncludeRollForwardInNativeHost()
4343
result.Args.Should().ContainAll("--roll-forward", "Major", fakeExecutable.Value);
4444
}
4545

46+
[Fact]
47+
public void WhenRunWithRollForwardOptionItShouldPreserveDuplicateArgumentsForwardedToTool()
48+
{
49+
(FilePath fakeExecutable, LocalToolsCommandResolver localToolsCommandResolver) = DefaultSetup("a");
50+
IEnumerable<string> testForwardArgument = ["--var", "a", "--var", "b"];
51+
52+
var result = localToolsCommandResolver.ResolveStrict(new CommandResolverArguments()
53+
{
54+
CommandName = "dotnet-a",
55+
CommandArguments = testForwardArgument
56+
}, allowRollForward: true);
57+
58+
result.Should().NotBeNull();
59+
result.Args.Should().ContainAll("--roll-forward", "Major", fakeExecutable.Value);
60+
// Verify duplicate forwarded arguments are preserved in order.
61+
result.Args.Should().Contain("--var a --var b");
62+
}
63+
4664
[Fact]
4765
public void WhenRunWithoutRollForwardOptionItShouldNotIncludeRollForwardInNativeHost()
4866
{

0 commit comments

Comments
 (0)