Skip to content

Fix dotnet tool runner stripping duplicate flags when rollForward is enabled#53725

Open
Copilot wants to merge 6 commits intomainfrom
copilot/fix-dotnet-tool-strip-duplicate-flags
Open

Fix dotnet tool runner stripping duplicate flags when rollForward is enabled#53725
Copilot wants to merge 6 commits intomainfrom
copilot/fix-dotnet-tool-strip-duplicate-flags

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 6, 2026

When a local tool has "rollForward": true in dotnet-tools.json (or --allow-roll-forward is passed), repeated options like --var a --var b were silently deduplicated before being forwarded to the tool — only the first --var survived.

Root cause

MuxerCommandSpecMaker.CreatePackageCommandSpecUsingMuxer used Enumerable.Except to strip --allow-roll-forward from the forwarded args. Except is a set operation — it deduplicates the source sequence as a side effect, collapsing all repeated arguments.

Fix

Replace Except with a Where predicate that filters only --allow-roll-forward entries:

// Before — silently deduplicates all args
arguments.AddRange(commandArguments.Except(rollForwardArgument));

// After — removes only --allow-roll-forward, preserves duplicates
arguments.AddRange(commandArguments.Where(arg =>
    !arg.Equals("--allow-roll-forward", StringComparison.OrdinalIgnoreCase)));

A test is added to ToolRunCommandTests verifying that --var a --var b survives the forwarding pipeline intact when rollForward is active.

Copilot AI and others added 2 commits April 6, 2026 21:57
…unner

Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/9a375444-f64b-4627-acbb-baf257cc890b

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
…ting

Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/9a375444-f64b-4627-acbb-baf257cc890b

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix dotnet tool runner stripping duplicate flags with rollForward Fix dotnet tool runner stripping duplicate flags when rollForward is enabled Apr 6, 2026
Copilot AI requested a review from marcpopMSFT April 6, 2026 21:59
@marcpopMSFT marcpopMSFT marked this pull request as ready for review April 10, 2026 18:19
@marcpopMSFT
Copy link
Copy Markdown
Member

Tested in codespaces with lbussell's repro.sh and confirmed the fix. @baronfel this is a regression in 10 but we haven't heard many complaints about it. Port to 4xx and wait for servicing pending feedback?

@baronfel
Copy link
Copy Markdown
Member

I suspect that folks just aren't using --allow-roll-forward in any large amount. Your plan seems sane though!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes dotnet tool run argument forwarding when roll-forward is enabled by ensuring repeated flags (e.g., --var a --var b) are not unintentionally deduplicated while stripping the internal --allow-roll-forward marker.

Changes:

  • Replace Enumerable.Except with a filtering Where clause to remove only --allow-roll-forward while preserving duplicate arguments.
  • Add a regression test to ensure duplicate forwarded arguments survive the roll-forward pipeline.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/dotnet.Tests/CommandTests/Tool/Run/ToolRunCommandTests.cs Adds coverage for duplicate forwarded arguments when roll-forward is active.
src/Cli/dotnet/CommandFactory/CommandResolution/MuxerCommandSpecMaker.cs Updates arg filtering logic to avoid Except-driven deduplication.

Comment thread test/dotnet.Tests/CommandTests/Tool/Run/ToolRunCommandTests.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@marcpopMSFT marcpopMSFT enabled auto-merge April 10, 2026 23:56
@marcpopMSFT
Copy link
Copy Markdown
Member

/backport to release/10.0.3xx

@github-actions
Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.3xx (link to workflow run)

@marcpopMSFT
Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

…ol-strip-duplicate-flags

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
auto-merge was automatically disabled April 13, 2026 21:13

Head branch was pushed to by a user without write access

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 13, 2026

@copilot resolve the merge conflicts in this pull request

Merged main into this branch and resolved the conflict in MuxerCommandSpecMaker.cs. The refactored version from main had re-introduced Except (which causes the deduplication bug), so the merge resolution applies our Where fix on top of main's new structure. Commit: fdd4c57.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet tool runner strips duplicate flags when rollForward: true

4 participants