11

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

TheDude
  • 1,421
  • 4
  • 29
  • 54

5 Answers5

5

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.

Shaun
  • 667
  • 8
  • 15
3

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.

TheDude
  • 1,421
  • 4
  • 29
  • 54
  • 9
    We use artifactory v5 and have same problem. Can you explain about your internal server and how did you fix that? – HamedH May 01 '19 at 16:37
1

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.

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27
  • I still get the error when I use 4.9.1: error NU1102: Unable to find package NuGet.Frameworks with version (>= 4.7.0) – TheDude Feb 08 '19 at 05:48
  • I think, fundamentally, the problem is that it's somehow trying to use "dotnet.exe" to do the restore. It seems to be successful when it uses nuget instead of dotnet.exe: Executing: "d:/vsts/a/_tool/dncs/2.2.100/x64/dotnet.exe" restore "./src/StorageRegistryPortal.sln" --source "http://nuget.bentley.com/nuget/Default" – TheDude Feb 08 '19 at 05:50
  • Can you try to execute the same set of execution in your local machine with verbose parameter and provide the error logs to me. I just wanted to understand that if you were able to execute this command from local or not? Is your VM agent have all the prerequisite which is required to build your solution? – Mohit Verma Feb 08 '19 at 05:54
  • This is what I get when I run "dotnet.exe" locally with the exact same command line as above: "Restore completed in 102.94 ms for D:\Repos\StorageRegistryPortal\src\StorageRegistryPortal\StorageRegistryPortal.csproj." So, dotnet.exe works fine locally. It just seems to break down in Azure DevOps. – TheDude Feb 08 '19 at 06:01
  • The VM agent works for all of our other solutions (which are mostly .net framework projects). So, this seems to be specific to .net core. – TheDude Feb 08 '19 at 06:03
  • If you have access to you VM agent. Can you go there and execute the same set of command and add this additional parameter in the command --verbosity Detailed. And please share the logs with me. – Mohit Verma Feb 08 '19 at 06:13
  • I don't have direct access to it myself. I'll have to get back to you on that. Could you confirm that "dotnet.exe" relies on "Nuget.Frameworks" when it does a nuget restore and that it specifically relies on version 4.7 and above for that? If that's the case, the issue may be that we're missing that version of Nuget.Frameworks on our nuget server. – TheDude Feb 08 '19 at 06:15
1

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.

Jess
  • 23,901
  • 21
  • 124
  • 145
0

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.