Nuget installation on max_path causes packages to be removed
I'm using LINQPad 5.05.02
I had the nuget package Microsoft.IdentityModel.Clients.ActiveDirectory installed previously.
LINQPad NuGet Manager showed that there was an update for this package. However, trying to install it hit Windows' 260 path limit (MAX_PATH).
The LINQPad error message shown is:
---------------------------
LINQPad
---------------------------
Error downloading 'Microsoft.IdentityModel.Clients.ActiveDirectory' - The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Additional warnings: Install failed. Rolling back...
---------------------------
OK
---------------------------
However, it did not roll back the update, it uninstalled the package entirely. I get the same error trying to install it again.
The path it was trying to install to was not particularly long. The final status bar message before the message box appeared was:
Adding package 'Microsoft.IdentityModel.Clients.ActiveDirectory' to folder 'C:\Users\<user name>\AppData\Local\LINQPad\NuGet.FW46\Microsoft.IdentityModel.Clients.ActiveDirectory'
Where my <user name> is 13 characters long.
The version of the package that I was trying to install is 2.26.305102204
I had the nuget package Microsoft.IdentityModel.Clients.ActiveDirectory installed previously.
LINQPad NuGet Manager showed that there was an update for this package. However, trying to install it hit Windows' 260 path limit (MAX_PATH).
The LINQPad error message shown is:
---------------------------
LINQPad
---------------------------
Error downloading 'Microsoft.IdentityModel.Clients.ActiveDirectory' - The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Additional warnings: Install failed. Rolling back...
---------------------------
OK
---------------------------
However, it did not roll back the update, it uninstalled the package entirely. I get the same error trying to install it again.
The path it was trying to install to was not particularly long. The final status bar message before the message box appeared was:
Adding package 'Microsoft.IdentityModel.Clients.ActiveDirectory' to folder 'C:\Users\<user name>\AppData\Local\LINQPad\NuGet.FW46\Microsoft.IdentityModel.Clients.ActiveDirectory'
Where my <user name> is 13 characters long.
The version of the package that I was trying to install is 2.26.305102204
Comments
When loading a query that uses a nuget package, the specific version option is not available, so the query needs to be loaded without downloading the nuget package, then the nuget package removed and the specific version re-added.
In the meantime, download the latest beta and change the NuGet package folder in NuGet | Settings. Change it to something short like c:\temp and you should be fine.
Edit: That worked.
This will copy any automatic namespace imports which have been set (by the "add selected namespaces in future without tasking" button)
This tool is very helpful to resolve the issue.