Open uladz-zubrycki opened 3 years ago
There seems to be another quirk to this issue:
After moving the locally installed tool to the default global-packages folder (as described by @v-zubritsky above), trying to restore the tool locally again using dotnet tool restore
won't even install it locally anymore.
This aspect renders our current workaround for this issue useless:
We simply called to tool by running dotnet giving it the full path to the installed tool-assembly, e.g.
dotnet <packages_folder>/trx2junit/1.3.1/tools/netcoreapp3.0/any/trx2junit.dll
This doesn't work reliably as the effect of dotnet tool restore
depends on the state of the default global-packages folder.
Cause: Local tools assuming there is only one nuget global cache, and it does not change (or it will start from scratch to populate the cache). It is also assumed by nuget. So local tools does not work well when changing the folder location on the fly.
This seems to work for us.
dotnet
is a client/server type application.
Make sure you shutdown the server with dotnet build-server shutdown
after you change the environment variable.
After that dotnet tool restore
and dotnet tool run
will use the new location.
I m also facing this issue, isn't no fix for this ? basically we need to just keep nuget packages on the default folder?
I stand corrected. dotnet tool restore
installs in the new place, but dotnet tool run
doesn't look there.
I have also encountered this problem. I had to copy the restored tool from the custom path to the ~/.nuget/packages
directory before dotnet tool run
would work.
Note that I encountered this problem using the new Dev Drive feature in Windows, which recommends redirecting NUGET_PACKAGES
to the Dev Drive for improved performance in the documentation. This seems like a significant gap in the new high performance development experience being touted.
https://learn.microsoft.com/en-us/windows/dev-drive/#storing-package-cache-on-dev-drive
Same here, my C drive does not have any more spaces so that I have to move the nuget packages to another drive, then boom, dotnet ef stopped working! I have to use mklink /J to make a directory junction from %userprofile%/.nuget to my new directory to make it working.
It's the same for me as in the issue description but with different tools. I have to handle it manually by moving the .NET tool packages to the service account's user folder.
As a workaround the shim files in $HOME/.dotnet/toolResolverCache
can be edited to fix the location of the tool. This way you don't need two nuget package dirs.
Same here, my C drive does not have any more spaces so that I have to move the nuget packages to another drive, then boom, dotnet ef stopped working! I have to use mklink /J to make a directory junction from %userprofile%/.nuget to my new directory to make it working.
Make a junction from$env:USERPROFILE\\.nuget\\packages
to $env:NUGET_PACKAGES
also works.
The fix we should go for here is to change the way we write and/or interpret the toolResolverCache
entries for each tool. It may be helpful to look at a resolver cache entry in detail:
{
"Version": "6.2.3",
"TargetFramework": "net8.0",
"RuntimeIdentifier": "any",
"Name": "fantomas",
"Runner": "dotnet",
"PathToExecutable": "C:\\Users\\<username>\\.nuget\\packages\\fantomas\\6.2.3\\tools/net6.0/any/fantomas.dll"
}
This tool hardcodes the path at install-time. We should do one of the following:
PathToExecutable
entirely for local tools and use the NuGet APIs at tool-run-time to compute the path to the dll to invokedotnet tool restore
and dotnet tool run
so that a dotnet tool restore
properly updates the absolute paths in the tool resolver cache and run is able to use that to look up the packagesPathToExecutable
and write it as a new property, and then ensure that if the nuget package path changes that a tool restore
operation is requested of the user to update the entriesMy personal preference is option 1 or 2, but all 3 would solve the user-facing problem.
Any news about this? It would help a lot also the adoption of DevDrive: https://learn.microsoft.com/en-us/windows/dev-drive/
My personal preference is option 1 or 2, but all 3 would solve the user-facing problem.
As a user I'd prefer option 1, as that would be the least surprising / magic and help me debug potential issues. Second would be option 4
Description
It's possible to change the path for nuget packages globally by setting
NUGET_PACKAGES
environment variable (there're other means of achieving it check the documentation for details) . Once that donedotnet tool
fails to start local tool. I guess it happens as tool was actually restored to nonstandard path,dotnet tool
is not able to find it there and consistently asks to rundotnet tool restore
.Steps
NUGET_PACKAGES
environment variable to some directory other than default%userprofile%/.nuget/packages
dotnet new tool-manifest
dotnet tool install paket
dotnet paket init
Expected result
Tool is invoked (which is
paket init
in current case)Actual result
Error message saying
Run "dotnet tool restore" to make the "paket" command available.
Running restore as suggested doesn't help. But everything works as expected after I manually move tool from the directory it was restored to to the
%userprofile%/.nuget/packages
.Haven't checked whether the same is actual for global tool installation, but would guess it is.
Environment