I right click on my solution file in my VS2010 and clicked Enable NuGet Package Restore, and I got an error message saying Unable to read package from path 'NuGet.CommandLine.2.7.1.nupkg'.
I googled around and don't see anything close.
Any clue?
The error message is usually because NuGet cannot open the NuGet package because it failed to download it. I would check your NuGet cache to see if the NuGet.CommandLine.2.7.1.nupkg file is zero bytes or smaller than expected. If so delete the file or clear the cache and try again. Sometimes the download can fail and NuGet leaves an empty file in the cache which causes problems on installing that NuGet package. You can also see the error if the NuGet package did not fully download, so the package will not be zero bytes but will not have fully downloaded and NuGet cannot open it. So it is worth deleting the NuGet package from the cache and retrying.
The NuGet cache is in the following directory:
%localappdata%\NuGet\Cache
You can also browse to the NuGet cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button.
Note that with newer versions of NuGet 2.8 this problem should be fixed. NuGet in later versions will download to a temporary file location and renamed once the download is completed so a partially download NuGet package will not be left in the cache.
go to this location and delete the nupkg file C:\ProgramData\chocolatey\lib\openjdk11
Related
I am having a strange (new) issue with Nuget in Visual Studio 2019 (v.16.9.0).
The Solutions are all ASP.NET Web Apps (MVC). I run on a local LAN. In the Nuget Package Manager 'Allow Nuget to download packages' and 'Automatically check for missing packages during build are both selected. I am using Packages.Config for management and the source is https://api.nuget.org/v3/index.json. VS is able to communicate via the Windows Defender Firewall. The target framework is .Net 4.7.2
The first issue is when I do a package restore after deleting the packages in the folder, it shows this error: The requested operation cannot be performed on a file with a user-mapped section open.
After I do the build, the files are being created correctly, including the new/existing DLLs. These replenished/refreshed DLLs work perfectly and the program runs. The strange part, however, is that the relevant NUPKG file has zero content (which is obviously triggering the error). The message eventually disappears after completion of the DLL downloads I assume. All good so far but with zero content in the NUPKG file.
When I now try to update a package things go awry, the Error List shows:
An error occurred while trying to restore packages. The file is not a valid nupkg. File path...
Then after a full restart of VS, I get this:
An error occurred while retrieving package metadata for 'ABC.3.5.0.2' from source 'I:....\packages'. 'ABC' being the first file in the package list. It therefore appears to be failing because the relevant NUPKG has no content.
I am able to paste any file freely to the packages folder and its sub-folders, indicating that there is no lock on the files. Also VS is able to write the rest of the package structure to the folder without issue.
IMHO this must mean that something is specifically locking/blocking the NUPKG files (or deleting their content during creation perhaps?). A search reveals nothing that I can see.
I even tried creating a brand new solution. During creation, the identical error message above popped up a warning. I also tried a few other of my existing solutions and got the same result. I updated VS and then I even did a full VS reinstall to the latest version, all to no avail.
I first noticed the issue after defining dependencies during an Azure Web App deployment (the Azure deployment tool optionally allows for updates to Nuget packages). After the Nuget update failed I set the option to blank and deployed anyway, the idea being to manually update the packages later. I cannot be certain, but I think this is when I discovered the issue. Could this process have changed a VS config setting somewhere perhaps?
Before the reinstall I opened the devenv.exe.config from inside VS and changed the IPV6 setting to false. No luck, so I have changed it back. I also did a test on one of the packages, downloading the package from the Nuget site directly and replacing the VS downloaded version, but I get the same errors.
Install failed. Rolling back... Package 'System.Buffers 4.5.1' does not exist in project 'ClickAuth_Graph' Package 'System.Buffers 4.4.0' already exists in folder 'I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages' Added package 'System.Buffers 4.4.0' to 'packages.config' Removing package 'System.Buffers 4.5.1' from folder 'I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages' This file is not a valid nupkg. File path...\packages\System.Buffers.4.5.1.nupkg Central Directory Corrupt An attempt was made to move the file pointer before the beginning of the file. At line:1 char 1 • Update-Package System.Buffers +CategoryInfo NotSpecified: (:) [Update-Package], Exception o FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
For the record I have one stale Nuget package in the portfolio. I don't use Github, but a repository was set upfront. I have not recently committed anything to Github.
Is there an expert out there that can help?
What you described is in a mess. And please try the following suggestions:
1) first clean all nuget caches or delete all cache files under C:\Users\xxx\.nuget\packages and I:\My Drive\Backups\ClickAuth_Graph (01_03_21)\packages.
I think that you have download the valid nuget packages on it and if your local exists the same name,version nuget package, it will always use the local wrong nuget package. So you have to delete them and then download the right package from the nuget package source.
2) enter Tools-->Options-->Nuget Package Manager-->Package Sources and make sure that you have enabled nuget.org package source, and if you have other own feed which you want to use, also enable it.
If not, please try to close VS, delete nuget.config under C:\Users\xxx\AppData\Roaming\NuGet. And then restart VS to re-generate it. Then, re-add your own feed if you have it.
3) run update-package -reinstall under Tools-->Nuget Package Manager--> Package Manager Console and then also delete bin and obj folder of your project.
4) you could also try to disable Azure deployment tool
Besides, if you have other solution level nuget.config, please check whether its content is suitable for your project. And if it is useless, you could remove them.
Does NuGet support global package installation like NPM and Composer? If so, how do I do that? Also, how do I reference globally installed packages in my Visual Studio projects?
So learning from #Lance's tips, I went ahead and checked %userprofile%\.nuget\packages folder, and indeed it contains all the packages that I have downloaded in the past. Unfortunately though, Visual Studio (I'm using Community 2019) does not allow you to install any of these packages into a new project. The Browse page in NuGet Package Manager UI displays online results only from nuget.org.
But then I found another clue. In Visual Studio Tools > Options > NuGet Package Manager > Package Sources, you can add custom sources. So I went ahead and added my cache folder as an alternate source.
Note that there is a separate "Machine-wide package sources" entry too that cannot be modified. I checked that folder and it contains mostly Microsoft's own packages (one exception that I found there was NewtonSoft.json). I have no idea how this folder is different from the nuget cache folder and how I can download a package to this folder.
So far so good. The Package Manager now shows all previously downloaded packages from cache when I select this source from the drop down (sources dropdown is in top-right corner). I can then select a package and install it from local source instead of downloading it from the Internet.
Hope this helps someone down the line.
I have created a new feed with in Package Release hub (VSTS), installed the credentials, then added the package source.
Now, I am using Visual Studio 2015 to install Micrososft.Aspnet.mvc to a project, however it gives the following error:
Exception 'System.AggregateException' thrown when trying to add source
'https://mysite.pkgs.visualstudio.com/DefaultCollection/_packaging/MyLogUtils/nuget/v3/index.json'.
Please verify all your online package sources are available.
I need to install NuGet packages normally, so I removed the feed from VSTS. However, the problem persists. How can this problem be resolved?
I met this issue today and fix it by following:
If you have delete the feed from VSTS, then you need to delete it from VS\Tools\Options\Nuget Package Manager\Package Sources:
If you didn't delete the feed in VSTS and want to use it, sign in with your VSTS team project account from VS upper right corner and restart VS:
This is may be an addition to the actual answer. I had to disable the check boxes as shown in below image to get the issue resolved. I think it might help to someone.
I had the same issue and I fixed issue by disabling my custom NuGet servers.
Go to Tools->Options->Nuget Package Manager and disable your custom NuGet servers
Since this is the first Page I hit with my Problem:
If you get the error for nuget.org site, increase Version number:
https://api.nuget.org/v3/index.json -> https://api.nuget.org/v4/index.json
under Tools->Options->Nuget Package Manager (see Image from #Eddie-MSFT)
V3 doesn't seem to work since today.
I also encountered that issue. I solved it by manually saving the index.json file and adding a local packaged source.
I had same issue, I resolved it by disabling its custom nuget server.
This exception might get when NuGet.Config file is readonly, for me unchecking the reaonly property of that file worked, generally, Nuget.config file exists in your project under .nuget folder.
File path project dir/.nuget/NuGet.Config
You have to ensure all your configured package source servers are available. Otherwise simply Go to Tools->Options->Nuget Package Manager and disable your custom NuGet servers.
One of the following might solve your problem.
Check and uncheck the package sources and click on update button, restart visual studio.
Uncheck all the other package source and only keep the one from nuget.org and click on update button, restart visual studio.
Once your package is install redo the changes as before.
'System.AggregateException' thrown when trying to add source 'https://devops.MyCompany.com/MC/_packaging/SharedFunctionalist/nuget/v3/index.json'. Please verify all your online package sources are available. One or more errors occurred.
Unable to load the service index for source https://devops.MyCompany.com/MC/_packaging/SharedFunctionalist/nuget/v3/index.json. Response status code does not indicate success: 401 (Unauthorized).
I got the same issue today.If you have noticed that It may asked you to enter DevOps credentials.That means it's request you to login your DevOps account.
There are two options for this type issue
1.Login with DevOps account(your Team Account) with your credentials.Then you can Install Nuget packages as usual.
2.Otherwise you have to delete existing package package source(which one is shared with team)by following below steps.
`Open Visual Studio ->Tools->Options->Nuget Package Manager-> Package Sources ->select that shared package Source and Delete it
Go to Tools->Options->Nuget Package Manager->Package Sources and uncheck the online NuGet Source named nuget.org https://api.nuget.org/v3/index.json. Also make sure your offline source is checked
I had the same problem. I resolved it by removing the checkmark from Tools/Options/Nuget Package Manager/Package Sources.
For me the package provoking the error was not showing up in the list of NuGet Sources (is it a bug?).
I had to go through the CLI (terminal) and enter
nuget sources
to get the list of Nuget sources.
Once the source causing the issue was listed I could remove it (you can also disable it)
nuget sources Remove -Name "source"
Documentation here
After that, restart Visual Studio
I want to know how I can debug a NuGet package not properly showing as updated. In my specific case the package for jQuery.Validation is (the only one left) in the "Update" list, but hitting the update button does nothing. Here's the dialog for Managing NuGet Packages for my solution:
Hitting the "Update" button will give an additional popup:
As you can see everything seems slightly grayed out (what does that mean?). Hitting "Ok" just brings me back to the other dialog.
The main problem is that I don't know how to debug this sort of problem. I've tried doing the following:
Opening the Package Manager Console to see if it logs any trouble. No dice.
Checking the jquery.validate.min.js file, which mentions version 1.13.1, which is in fact the one mentioned in the dialog as the newest version.
Checking the packages.config file, which also mentions my solution includes version 1.13.1.
Restarting Visual Studio. No dice.
Remove the package. Re-add the package. No dice (not even after restarting Visual Studio again).
Is this just a bug in the Package Manager or the package? How can I further debug the root cause of this problem?
I'm using Visual Studio 2012, have updated the product as well as all extensions (including the NuGet package manager). The solution was originally based on an MVC 2 template, and has been updated for each major MVC release (currently up to MVC 5). Only this particular package is giving trouble, I've succesfully updated 10+ other packages just before this one.
This can happen if you have an old NuGet package left in the packages directory.
When managing packages for the solution the NuGet dialog will show updates for all packages that are in the packages directory even if they are not installed into any projects. If you manage the packages for the project on its own the NuGet dialog would not show any package updates as being available.
So the workaround is to remove the unwanted NuGet package from the packages directory.
I am getting an error when trying to enable package restore in a new solution I just created. The error in VS2012 is:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Unable to read package from path 'NuGet.Build.2.7.0.npkg'.
I tried opening the solution in VS2010 to work around the problem and I am also getting an error when trying to enable package restore, but the message is different:
NuGet Package Manager
An error occurred while configuring the solution to restore NuGet
packages on build
Archive file cannot be size 0.
I tried creating a new solution, but got the same result.
I then tried doing a repair on VS2012 update 3 and rebooting. Still getting the problem.
I also scanned the folder, project, and solution file for anything NuGet or .nupkg, but there is nothing there.
So how can I get this feature working again? The last time I used it was about a week ago, and I don't remember specifically what I changed since then. I uninstalled the VS Power Tools package that I installed about a week ago, but that didn't fix the problem either.
Update
I followed the "removal" instructions here and used a project I already have as a template to enable package restore manually. However, I am still looking for a better solution because this is a feature I use frequently.
I also tried uninstalling and reinstalling NuGet from visual studio, but I still get the same issue. If memory serves correctly, there was a recent NuGet update (is there a log for VS extension installation so I can check?).
I suspect that the NuGet.Build.2.7.0.npkg file is zero bytes due to a failed download. NuGet.Build.2.7.0.npkg is the NuGet package that Visual Studio downloads in order to enable package restore for your solution.
Take a look in your cache and see if this file is zero bytes. If so then delete the file or clearing the cache and try enabling package restore again. The cache is under your profile in a directory similar to:
C:\Users\YourUsername\AppData\Local\NuGet\Cache
You can also browse to the cache from inside Visual Studio by opening the Package Manager Settings, selecting General and clicking the Browse button.
All of the previous answers, plus this one: can you run .\nuget\nuget.exe update -self if this is a solution in which package restore was previously enabled?
check whether your nuget package manager is updated one or not.
Check this from Tools-> Extensions and Updates -> Updates
Update your Nuget Package Manager and then it will work