sdk: 'Dotnet tool restore' does not work correctly when NUGET_PACKAGES (global-packages) is set to an alternative location
Issue Title
‘dotnet tool restore’ does not work correctly when NUGET_PACKAGES (global-packages) is set to an alternative location.
Description
If you set NUGET_PACKAGES to an alternate folder. “D:\cache” on a build agent for instance,
dotnet tool restore # and then directly after
dotnet paket info # or paket <whatever>.
will fail with $lastexitcode=1 and
Run "dotnet tool restore" to make the "paket" command available.
The same error happens for at least two other tools as well. gitversion.tool and dotnet-fsharplint.
Repro steps
See this minimal example: https://github.com/da9l/dotnetpaketProblem_minimalExample/blob/master/readme.md
Expected behavior
it should work.
Actual behavior
fail with $lastexitcode=1 and
Run "dotnet tool restore" to make the "paket" command available.
Known workarounds
Don’t set NUGET_PACKAGES to anything non-standard.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 25
- Comments: 17 (1 by maintainers)
I just want to share my findings; that I managed to work around it by deleting the %USERPROFILE%\.dotnet\toolResolverCache folder before running dotnet tool restore.
deleting
toolResolverCacheseems to fix the issue. On linux it’s at~/.dotnet/toolResolverCacheThis might have renewed relevance given the release in Windows’ Dev channel preview of Dev Drive, where an explicitly called-out use case is to redirect package caches there. I recently hit this myself and got around it with the workaround, but when this hits GA more developers may encounter this.
We ran into this issue as well. As a workaround, we had to create a symbolic link from the standard location to our customized location so that the dotnet cli would behave properly.
> mklink /J "C:\Users\username\.nuget\packages" "X:\CustomPath\.nuget\packages"Redirecting
globalPackagesFolderis actually quite important for some scenarios, e.g. testing custom MSBuild SDKs. It’s not really reasonable to tell people they might have to nuke a cache in their home directory to work on my project.This is on our list to tackle - it’s one of the things that we have more control over now that we’re not doing an behind-the-scenes
dotnet restoreon a specially-formatted project file. We’re in more direct control of the tool package download so can respond to changes like this more directly.This workaround does seem to be sufficient for now. Are there plans to fix this issue, however?
hi, same issue here, its connected to v 1.0.1 , if i install 0.50 it works, if i upgrade it fails always with
win 10 x64 sdks installed 2.1.811 [C:\Program Files\dotnet\sdk] 3.1.301 [C:\Program Files\dotnet\sdk] 5.0.100 [C:\Program Files\dotnet\sdk]
nuget
how to reproduce install the tool globally, uninstall, install and uninstall locally, repeat locally, doesnt work
Like you say, it’s pretty rough in a concurrent test environment. It’s causing some headaches.
Same problem for us. We run tests in parallel and those tests do project restores which often have the same set of files that need to be downloaded from a nuget feed. We put in the override in the nuget.config to make each test use a separate packages cache to avoid the concurrency problem. Because of this issue: https://github.com/NuGet/Home/issues/8129
But now that we’re trying to incorporate use of tools, the restore fails on some machines. Deleting the ‘toolResolverCache’ folder for the user helps, but that’s terrible in a concurrent test environment where multiple tests need the tool. And we also do not want to install stuff globally.