Repository navigation
[release/10.0.1xx] Fix dotnet tool exec / dnx failing when tool exists in dotnet-tools.json but not yet restored - #53658
Merged
baronfel merged 3 commits intoMay 13, 2026
Conversation
…t not restored Co-authored-by: marcpopMSFT <[email protected]>
Member
|
/tactics |
Member
|
Approved over mail. |
baronfel
enabled auto-merge (squash)
May 13, 2026 17:32
baronfel
approved these changes
May 13, 2026
This was referenced May 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #53361 to release/10.0.1xx
/cc
@baronfel@CopilotTactics
Summary
dotnet tool execanddnxfail with "Run 'dotnet tool restore' to make the command available" when a tool is listed in a localdotnet-tools.jsonmanifest butdotnet tool restorehas not yet been run. The root cause is inToolExecuteCommand.Execute(): after callingToolPackageRestorer.InstallPackage()to download the package, the resultingSaveToCachetuple was never passed tolocalToolsResolverCache.Save(). The subsequentLocalToolsCommandResolverthus found an empty cache and reported the tool as unavailable. The fix adds the missinglocalToolsResolverCache.Save()call immediately after a successful restore. This is a minimal, surgical change appropriate for a servicing release — it only touches the first-download code path and is guarded by a null check that preserves existing behavior for already-restored tools.Customer Impact
Any user of
dotnet tool exec <toolId>ordnx <toolId>in a directory where adotnet-tools.jsonmanifest references that tool (butdotnet tool restorehas not been run) will receive the confusing error: "Run 'dotnet tool restore' to make the 'X' command available." This directly contradicts the design intent ofdotnet tool exec/dnx, which are supposed to download and run tools on demand without prior setup. The issue was reproduced on SDK 10.0.103 (Linux x64) and affects all platforms. It is particularly impactful in CI/scripting scenarios. The only known workaround is to delete or rename the localdotnet-tools.jsonbefore running the command.Regression?
Unknown — the issue was first reported against SDK 10.0.103. The original fix PR (#53361) does not identify a specific commit or earlier PR that introduced the regression. It may be a long-standing omission in the
dotnet tool execimplementation rather than a recent regression.Testing
ToolExecSucceedsWhenToolIsInLocalManifestButNotRestoredintest/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cscovers both theexecanddnxcommand variants. The test creates adotnet-tools.jsonmanifest referencing the tool, then runs the command without a priordotnet tool restore, asserting that the command passes and produces expected output (Hello Tool!).dotnet tool exec/dnxfailing when tool exists indotnet-tools.jsonbut not yet restored #53361 (merged tomain); this PR is a direct backport with no additional changes.Risk
Low. The code change is 8 lines in a single method (
ToolExecuteCommand.Execute()). TheSaveToCachenull check ensures the new code only runs on first download (when the tool is not yet in the on-disk cache); the existing behavior for already-restored tools is completely unchanged. A dedicated end-to-end regression test covers the fixed scenario for bothexecanddnx. The change is isolated to the local-tool execution path and does not affect global tool installation or other SDK commands.