Skip to content

Conversation

@rolfbjarne
Copy link
Member

Fixes #11432.

@ghost ghost added Area-Infrastructure untriaged Request triage from a team member labels Sep 19, 2024
@marcpopMSFT
Copy link
Member

if approved, it would need documentation: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables

@rolfbjarne
Copy link
Member Author

if approved, it would need documentation: learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables

I can do that if approved.

@rolfbjarne
Copy link
Member Author

@dsplaisted is this something you can approve?

@github-actions
Copy link
Contributor

Due to lack of recent activity, this PR has been labeled as 'Stale'. It will be closed if no further activity occurs within 7 more days. Any new comment will remove the label.

@github-actions github-actions bot added the stale label Sep 22, 2025
@dsplaisted
Copy link
Member

I think we probably still want this.

@github-actions github-actions bot removed the stale label Sep 23, 2025
Copilot AI review requested due to automatic review settings December 10, 2025 10:10
Copy link
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

This PR adds support for overriding the default tools resolver cache path using the DOTNET_TOOLS_RESOLVER_CACHE_FOLDER environment variable, addressing issue #11432. This allows users to customize where the shim files for locally installed tools are stored, which is useful for scenarios where the default location under $HOME/.dotnet/toolResolverCache is not suitable.

Key Changes

  • Modified CliFolderPathCalculator.ToolsResolverCachePath to check the DOTNET_TOOLS_RESOLVER_CACHE_FOLDER environment variable before falling back to the default path
  • Added a test to verify the environment variable override functionality works correctly
  • Updated documentation to reflect the new environment variable

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Cli/Microsoft.DotNet.Configurer/CliFolderPathCalculator.cs Implements environment variable override for tools resolver cache path
test/dotnet.Tests/CommandTests/Tool/Restore/ToolRestoreCommandTests.cs Adds test coverage for the new environment variable override
documentation/manpages/sdk/dotnet-tool-install.1 Documents the new environment variable option
documentation/manpages/sdk/dotnet-environment-variables.7 Adds documentation for the DOTNET_TOOLS_RESOLVER_CACHE_FOLDER variable

public static string ToolsResolverCachePath => Path.Combine(DotnetUserProfileFolderPath, ToolsResolverCacheFolderName);
public static string ToolsResolverCachePath =>
Environment.GetEnvironmentVariable("DOTNET_TOOLS_RESOLVER_CACHE_FOLDER") ??
Path.Combine(DotnetUserProfileFolderPath, ToolsResolverCacheFolderName);
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

Inconsistent indentation: This line has an extra space. It should align with line 18 (12 spaces of indentation), but appears to have 13 spaces. Please adjust the indentation to match the pattern used in lines 17-18.

Suggested change
Path.Combine(DotnetUserProfileFolderPath, ToolsResolverCacheFolderName);
Path.Combine(DotnetUserProfileFolderPath, ToolsResolverCacheFolderName);

Copilot uses AI. Check for mistakes.
.PP
Local tools are stored in the NuGet global directory, whatever you\[cq]ve set that to be.
There are shim files in \f[V]$HOME/.dotnet/toolResolverCache\f[R] for each local tool that point to where the tools are within that location.
There are shim files in \f[V]$HOME/.dotnet/toolResolverCache\f[R] for each local tool that point to where the tools are within that location (this path can be overridden with the \f[V]DOTNET_TOOLS_RESOLVER_CACHE_FOLDER\f[R] environment variable).
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

According to repository guidelines, files under documentation/manpages/sdk are generated and should not be manually modified. These changes should be made to the source documentation files instead, and the manpages should be regenerated from those sources.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +555 to +557
.SS \f[V]DOTNET_TOOLS_RESOLVER_CACHE_FOLDER\f[R]
.PP
Overrides the default location ($HOME/.dotnet/toolResolverCache) for the shim files for locally installed tools.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

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

According to repository guidelines, files under documentation/manpages/sdk are generated and should not be manually modified. These changes should be made to the source documentation files instead, and the manpages should be regenerated from those sources.

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

'Dotnet tool restore' does not work correctly when NUGET_PACKAGES (global-packages) is set to an alternative location

4 participants