Skip to content

[release/11.0.1xx] Fix dnx offline package cache fallback - #55958

Merged
baronfel merged 12 commits into
release/11.0.1xxfrom
baronfel-fix-dnx-offline-cache-fallback
Sep 16, 2026
Merged

baronfel merged 12 commits into
release/11.0.1xxfrom
baronfel-fix-dnx-offline-cache-fallback

Conversation

@baronfel

Copy link
Copy Markdown
Member

Summary

  • reuse exact compatible tool versions from the global NuGet cache without contacting configured feeds
  • probe feeds briefly for floating versions, then fall back to the best compatible cached version when feeds are unavailable
  • preserve cache-bypass behavior for --no-cache and NO_CACHE

Testing

  • built src\Cli\dotnet\dotnet.csproj
  • passed 6 focused dnx and dotnet tool exec cache fallback tests

Fixes #50579

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Keep the cache and cancellation helpers on the concrete downloader so shared interfaces and unrelated mocks remain unchanged.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Copilot AI lite review requested due to automatic review settings August 27, 2026 00:08
@baronfel
baronfel requested a review from a team as a code owner August 27, 2026 00:08
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates dotnet tool exec / dnx tool resolution to better support offline (or partially offline) scenarios by reusing already-downloaded tool packages from the global NuGet cache and only probing feeds briefly when a floating version is requested.

Changes:

  • Add cache-first resolution logic for ToolExecuteCommand, including a short, configurable feed probe and honoring NO_CACHE.
  • Add ToolPackageDownloader helpers to select the best matching cached tool and to resolve versions with cancellation support.
  • Extend NuGetPackageDownloader to accept cancellation and treat HttpRequestException similarly to FatalProtocolException when IgnoreFailedSources is enabled.
  • Add end-to-end regression tests covering cached fallback behavior and cache bypass.

Reviewed changes

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

File Description
test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs Adds end-to-end tests for cached tool fallback and cache-bypass behavior.
src/Cli/dotnet/ToolPackage/ToolPackageDownloader.cs Adds cached-tool selection and cancellable version/source lookup.
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs Adds cancellable version+source resolution and improved handling of HttpRequestException with IgnoreFailedSources.
src/Cli/dotnet/Commands/Tool/Execute/ToolExecuteCommand.cs Implements cache-first tool execution logic with feed probing, timeout, and NO_CACHE support.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
@baronfel
baronfel requested a review from dsplaisted September 3, 2026 17:46
@baronfel

baronfel commented Sep 3, 2026

Copy link
Copy Markdown
Member Author

@dsplaisted this PR allows dnx to work in offline scenarios, should be hopefully straightforward!

Use System.CommandLine cancellation tokens for global tool install and update version resolution, while preserving synchronous command entry points for direct callers.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 164ae8b0-7bdd-40e6-aa03-69ee79fc0488
@baronfel
baronfel requested a review from a team as a code owner September 16, 2026 16:59

@lbussell lbussell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A good follow-up might be to make async commands more first-class in the .NET CLI / in CommandBase. As far as I can tell, I don't think the synchronous version of ToolExecuteCommand.Execute() is called from anywhere.

@baronfel

baronfel commented Sep 16, 2026 •

Copy link
Copy Markdown
Member Author

A good follow-up might be to make async commands more first-class in the .NET CLI / in CommandBase. As far as I can tell, I don't think the synchronous version of ToolExecuteCommand.Execute() is called from anywhere.

I do agree, but pre-LLMs didn't want to do all of the grunt work myself.

@baronfel
baronfel enabled auto-merge September 16, 2026 18:59
@baronfel
baronfel merged commit d2f8871 into release/11.0.1xx Sep 16, 2026
25 checks passed
@baronfel
baronfel deleted the baronfel-fix-dnx-offline-cache-fallback branch September 16, 2026 19:24

This branch had an error being deployed

1 failed deployment
copilot-pat-pool — 8c758c74 Deployed Sep 16, 2026 by baronfel via pre_activation #5305
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants