maxx
maxx

Reputation: 493

An error occurred while retrieving package metadata for ***

This has been asked many times before. The solution (which works for me) is to delete the *** package(s) from the packages.config file (this is enough), and from the packages folder.

This is a bad solution for me because it has to be repeated every time I want to install some nuget package. The culprit package varies, but it tends to be the same package(s) every time (Newtonsoft.Json/NETStandard.Library etc...), until I delete all packages and try to reinstall them (this sometimes changes the culprit package).

Is there a solution for this? It is nerve-wrecking to have to do this manual fix all the time. And I think it points to some major underlying problem that I would like to amend in my project.

Upvotes: 30

Views: 43199

Answers (8)

BDarley
BDarley

Reputation: 1275

I tried all the deleting my .vs folder, cleared local Nuget cache but didn't help. I went to the console to manually update nuget

nuget update -self

This resulted in

Checking for updates from https://api.nuget.org/v3/index.json [https://api.nuget.org/v3/index.json].


GET https://api.nuget.org/v3/registration5-gz-semver2/nuget.commandline/index.json

BadRequest https://api.nuget.org/v3/registration5-gz-semver2/nuget.commandline/index.json 170ms
An error occurred while retrieving package metadata for 'NuGet.CommandLine' from source 'https://api.nuget.org/v3/registration5-gz-semver2/'.

Response status code does not indicate success: 400 (One of the request inputs is out of range.).

I then performed a GET in the browser to see what would return

https://api.nuget.org/v3/registration5-gz-semver2/nuget.commandline/index.json

This returned

<Error>
<Code>OutOfRangeInput</Code>
    <Message>One of the request inputs is out of range. RequestId:41dba6a9-d01e-003e-1a5f-8c2a88000000 Time:2025-03-03T17:09:31.0867687Z</Message>
</Error>

So finally went to https://status.nuget.org

and found the service was down for Visual Studio

enter image description here

Upvotes: 0

Unshortafleur
Unshortafleur

Reputation: 1

As dumb as it seems, the thing that worked for me was to add / at the end of my artifactory repo url in my nuget.config. from

<add key="Artifactory_Nuget_Org" value="https://MyArtifactoryBaseUrl/artifactory/api/nuget/v3/nuget-proxy-nuget-org" />

to

<add key="Artifactory_Nuget_Org" value="https://MyArtifactoryBaseUrl/artifactory/api/nuget/v3/nuget-proxy-nuget-org/" />

Upvotes: 0

Ashish
Ashish

Reputation: 1

We need to use the API endpoint for NuGet.org: https://learn.microsoft.com/en-us/nuget/nuget-org/overview-nuget-org#api-endpoint-for-nugetorg

API endpoint for NuGet.org To use NuGet.org as a package repository with NuGet clients, you should use the following V3 API endpoint: Nuget package restore for missing packages: https://api.nuget.org/v3/index.json Older clients can still use the V2 protocol to reach NuGet.org. However, please note, NuGet clients 3.0 or later will have slower and less reliable service using the V2 protocol: https://www.nuget.org/api/v2 (The V2 protocol is deprecated!)

Just Add https://api.nuget.org/v3/index.json as package source and again try to laod the Nuget packages

Upvotes: 0

Daniel Danielecki
Daniel Danielecki

Reputation: 10590

Changing the desired version to be fetched in packages.config did the trick. If you'll relaunch Visual Studio then you'll see in the Manage NuGet Packages... that the dependency is updated. It didn't require from me to do it twice - this dependency has been updated based on the PackageReference of this NuGet https://www.nuget.org/packages/System.Net.Http/

Upvotes: 0

Vladimir Pavlov
Vladimir Pavlov

Reputation: 51

What worked for me in VS2022-

  • Tools -> NuGet Package Manager -> Package Manager Settings
  • Here click "Clear all NuGet Cashe".
  • Restart VS.

Should be ok now.

Upvotes: 5

Gauri
Gauri

Reputation: 21

I had the same issue with my visual studio 2015.

But Uninstalling the Nuget Package Manager and re-installing the same worked for me.

In Visual Studio, from the "Tools" menu choose the "Extensions and Updates" option. Top right "Search Installed" bar, sear ch for Nuget Package Manager Uninstall the Nuget Package Manager for Visual Studio 2015. Restart Visual Studio. Re-Install the same with the same steps.

close the visual studio and again open

Upvotes: 2

Rachit
Rachit

Reputation: 39

I had the same issue with my visual studio 2015.

But Uninstalling the Nuget Package Manager and re-installing the same worked for me.

  1. In Visual Studio, from the "Tools" menu choose the "Extensions and Updates" option.
  2. Top right "Search Installed" bar, sear ch for Nuget Package Manager
  3. Uninstall the Nuget Package Manager for Visual Studio 2015.
  4. Restart Visual Studio.
  5. Re-Install the same with the same steps.

Upvotes: 2

SF1Dev
SF1Dev

Reputation: 808

Update the Visual Studio Package Manager to the latest version using the below steps and the ongoing issue will disappear.

  1. In Visual Studio, from the "Tools" menu choose the "Extensions and Updates" option.
  2. From the dialog that appears, expand the "Updates" node from the tree at the left side.
  3. Select the "Visual Studio Gallery" option from the tree.
  4. Finally, look for the Package Manager update in the list of updates at the right side of the dialog and click the "Update" button beside it.

Upvotes: 62

Related Questions