Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Restore Failing to See that Packages are not Installed

Our CI server fails to restore our NuGet packages when attempting to build a project. It thinks they are already installed. Here are the logs:

build 16-Apr-2015 12:56:38 C:\build-dir\IOP-IOL-JOB1>nuget restore IOHandlerLibrary.sln -NoCache build 16-Apr-2015 12:56:39 All packages listed in packages.config are already installed.

What causes NuGet to believe that the packages are installed? Is it something in the solution or in the project file?

like image 784
Scotty H Avatar asked Apr 16 '15 20:04

Scotty H


People also ask

How do I fix NuGet recovery failed?

Quick solution for Visual Studio usersSelect the Tools > NuGet Package Manager > Package Manager Settings menu command. Set both options under Package Restore. Select OK. Build your project again.

How do I force a NuGet package to restore?

Enable package restore by choosing Tools > Options > NuGet Package Manager. Under Package Restore options, select Allow NuGet to download missing packages. In Solution Explorer, right click the solution and select Restore NuGet Packages.

What is NuGet package restore?

Restore packages with NuGet Package Restore. NuGet Package Restore restores all of a project's dependencies that are listed in either a project file or a packages. config file. You can restore packages manually with nuget restore , dotnet restore , msbuild -t:restore , or through Visual Studio.


1 Answers

I also had the same issue, but for me even removing the packages directory would result in All packages listed in packages.config are already installed..

Turns out the packages.config file was invalid. Well, sort of:

<packages xmlns="urn:packages">
  ...
</packages>

I do not know which tool inserted the XML namespace, but it is the reason why nuget was not trying to install any packages.

Changing this back to

<packages>
  ...
</packages>

solved it for me.

like image 52
cbley Avatar answered Sep 18 '22 08:09

cbley