Fix dotnet tool runner stripping duplicate flags when rollForward is enabled#53725
Fix dotnet tool runner stripping duplicate flags when rollForward is enabled#53725
Conversation
…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>
|
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? |
|
I suspect that folks just aren't using |
There was a problem hiding this comment.
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.Exceptwith a filteringWhereclause to remove only--allow-roll-forwardwhile 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. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
/backport to release/10.0.3xx |
|
Started backporting to |
|
@copilot resolve the merge conflicts in this pull request |
…ol-strip-duplicate-flags Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Head branch was pushed to by a user without write access
Merged |
When a local tool has
"rollForward": trueindotnet-tools.json(or--allow-roll-forwardis passed), repeated options like--var a --var bwere silently deduplicated before being forwarded to the tool — only the first--varsurvived.Root cause
MuxerCommandSpecMaker.CreatePackageCommandSpecUsingMuxerusedEnumerable.Exceptto strip--allow-roll-forwardfrom the forwarded args.Exceptis a set operation — it deduplicates the source sequence as a side effect, collapsing all repeated arguments.Fix
Replace
Exceptwith aWherepredicate that filters only--allow-roll-forwardentries:A test is added to
ToolRunCommandTestsverifying that--var a --var bsurvives the forwarding pipeline intact whenrollForwardis active.