TheDude
TheDude

Reputation: 1531

error NU1102: Unable to find package NuGet.Frameworks with version (>= 4.9.3)

I'm getting this error when I try to build a .NET Core solution with Azure DevOps:

error NU1102:  Unable to find package NuGet Frameworks with version (>= 4.9.3)
error NU1102:   - Found 33 version(s) in http://nuget.bentley.com/nuget/Default [ Nearest version: 4.7.0-preview1-4986 ]

The error occurs in the Cake script when a NuGet restore is being executed by dotnet.exe CLI:

Executing: "d:/vsts/a/_tool/dncs/2.2.100/x64/dotnet.exe" restore "./src/StorageRegistryPortal.sln" --source "http://nuget.bentley.com/nuget/Default"

It tries to restore the NuGet packages from the solution file before throwing the NU1102 error above:

 Restoring packages for d:\vsts\a\2921\s\src\StorageRegistryPortal\StorageRegistryPortal.csproj...

Nothing in my solution is referencing this "NuGet.Frameworks" package. So, I wonder if it is the "dotnet.exe" CLI itself that depends on this nuget package before it can restore the rest of the NuGet packages. Also, this only happens in AzureDevops. When I execute the build/cake script on my local PC, it is able to successfully restore all of the nuget packages with no issues.

I've already tried adding a "Use Nuget 4.9.3" task to the build pipeline, but I get the same error.

NOTE: If I remove that "Use Nuget 4.9.3" task, then the error changes to (>= 4.7.0). So, it appears to be looking for the Nuget.Framework that matches the current version of nuget.exe but not finding it.

Here is the screenshot of my build pipeline setup: enter image description here

Upvotes: 17

Views: 29740

Answers (6)

AXU
AXU

Reputation: 51

If you are experiencing nuget cache problems, Goto this folder and delete all! %localappdata%\NuGet\v3-cache

https://learn.microsoft.com/en-us/nuget/consume-packages/managing-the-global-packages-and-cache-folders

Upvotes: 5

Jess
Jess

Reputation: 25039

This is an easy thing to try first

We use an internal NuGet server as well, but I don' think that is the issue in this case.

I had a package I made with version 0.8.3, 0.9.0, and 0.9.1. They did have some breaking changes in each version. So the code was not compiling. I got error NU1102 Unable to find package... on 0.9.1.

I went back to 0.8.3 and then to 0.9.1 again and finally it worked. (I was editing the csproj file PackageReference, Version)

My suspicion is that the compile errors were messing up nuget.

Upvotes: 1

Ivan Huzikov
Ivan Huzikov

Reputation: 1

Try to download Nuget.Framework of higher version from here https://www.nuget.org/downloads. In my case it was a problem with version 5.0.0 and I installed 5.0.2 then error disappeared.

Upvotes: 0

Shaun
Shaun

Reputation: 697

TL;DR

This sometimes happens when running dotnet restore on one of my Linux/Ubuntu build servers when pulling from a private Azure DevOps Artifacts/Packages NuGet repo.

The solutions that work for me:

  1. Rebooting the Linux machine, or
  2. Deleting the NuGet cache at ~/.local/share/NuGet/v3-cache/[directory-with-name-of-my-private-nuget-repo]

Background

The error I get is:

error NU1102: Unable to find package [Name-of-my-custom-nuget-package] with version (>= 5.0.116)

I have a nuget.config file that is properly configured to pull down my NuGet packages.

The error is complete nonsense.

  1. The version does exist
  2. Other Linux boxes have no problems running dotnet restore and getting the version of the package
  3. I can run dotnet restore on the same Linux machine for other (older) versions and it's fine

It just seems that dotnet restore decides, for whatever reason, that it's not even going to try to look for the new version of the package.

I've generally found Azure DevOps private NuGet repos secured with AAD to be especially problematic and annoying when dealing with Linux. It really needs some love and attention from the NuGet team.

Upvotes: 6

TheDude
TheDude

Reputation: 1531

I was finally able to resolve this issue. It turns out there was a breaking change from the nuget.org folks which caused our internal nuget server to fail to serve the 4.7 and 4.9.3 versions of NuGet.Frameworks. This is an essential nuget library which is required by dotnet.exe to restore nuget packages. For .net core projects, that framework needs to be version 4.7 or higher. Anyway, the resolution was that we had to make adjustments to our internal nuget server to account for the changes from nuget.org.

Upvotes: 3

Mohit Verma
Mohit Verma

Reputation: 5296

Could you please have a try to use Nuget 4.9.1 as screenshot then run your build again?

enter image description here

Hope it helps.

Upvotes: 2

Related Questions