Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins not finding a nuget package

I'm setting a Jenkins CI server. I got the first step to run properly:

nuget restore -NonInteractive  -ConfigFile Nuget.config -Verbosity Detailed -NoCache

That works properly, but when I want to compile the app with:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe

and ${WorkSpace}\src\Weather.App.csproj It throws this error:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : The package HockeySDK.Core with version 4.1.6 could not be found in C:\WINDOWS\system32\config\systemprofile\.nuget\packages\. Run a NuGet package restore to download the package. [C:\Program Files (x86)\Jenkins\workspace\MyApp\Weather\Weather.App.csproj]

The weird thing is that it the Hockey package clearly exists in the path: enter image description here

If I run the same command IN my VS2017 local project, everything runs smoothly. But the jenkins server (which is in my same machine) does not build it properly.

Any ideas? Thanks

like image 433
Fritjof Berggren Avatar asked Apr 07 '17 10:04

Fritjof Berggren


1 Answers

Here's the trick.

  1. Put nuget.exe somewhere on he build server.

  2. Ensure nuget.exe is in the PATH environment variable.

  3. Restart Jenkins so that it picks up the updated PATH environment variable

  4. Upgrade NuGet to the latest version

    nuget.exe update --self

In the Jenkins job calling rebuild against MSBUILD won't successfully restore the nuget packages

Add a Windows Batch step after the MSBUILD Clean and before the MSBUILD Rebuild like so:

nuget restore <your_solution_file>.sln

Path to solution file is workspace relative.

This will create the packages directory as you would expect.

like image 63
Andrew Gray Avatar answered Sep 27 '22 01:09

Andrew Gray