error NU1101: Unable to find package ''. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org

Viewed 7887

I manage an application that is continuously integrated via Jenkins. Continuous integration usually happens via a separate Jenkins server, but I am trying to mimic the process of editing source code, committing to source control and then building in Jenkins on my home PC. This usually occurs at my office, but I am working from home now and do not yet have a VPN set up, so I am attempting to continue development at home.

At home, the Jenkins server is my PC, localhost:8080. Git is our source control manager. The application's solution builds fine in Visual Studio on my PC. It depends on some nuget packages stored in a folder on my C: drive. The source code, including the solution, is also stored in a folder on my C: drive. In Visual Studio's NuGet Package Manager, these are my settings.

enter image description here

enter image description here

I get the following error message when Jenkins attempts to restore packages during a build.

enter image description here

The NuGet packages that Jenkins cannot find are the packages in the folder on my C: drive. It seems that Jenkins is unaware of my Visual Studio NuGet Package Manager settings and my C: drive NuGet packages folder and trying to look in the Microsoft Visual Studio Offline Packages directory at "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\". This is confusing, because Jenkins is trying to build the same solution which builds fine on my PC.

My initial thoughts are that the Jenkins build job needs to be configured to "see" the NuGet packages folder which is on my C: drive, but I am not sure how to configure Jenkins to "see" that folder. Since my solution, the NuGet packages folder and Jenkins live on the same machine, I assumed that Jenkins would have no issues "seeing" the NuGet packages folder on my C: drive.

What am I missing here? I appreciate any help.

2 Answers

I faced this issue. Make sure you have the official NuGet package reference in the NuGet.config. To do so follow these steps

  1. Open your Visual Studio
  2. Go to Tools -> Nuget Package manager -> Package Manager Settings
  3. A setting menu will open, Select Package sources under Nuget Package Manager
  4. Look for a package with the name Nuget having this source address https://api.nuget.org/v3/index.json if not add it and click ok
  5. Clean your solution and build it again. It should solve your problem

I tried this exercise in Visual Studio 2019 professional

Jenkins is unaware of my Visual Studio NuGet Package Manager settings

You have configured the NuGet options for yourself, but the Jenkins service runs as a different user (namely "SYSTEM") by default.

Solution:

Configure the Jenkins service to run under either your current user account or create a new account specifically for Jenkins. The latter is typically done in an organizational environment. You would log in as the Jenkins user and adjust NuGet options so the Jenkins service will see them.

Related