NuGet Restore Failing to See that Packages are not Installed
Asked Answered
R

3

14

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?

Repentant answered 16/4, 2015 at 20:8 Comment(0)
I
1

NuGet will check the packages directory for the solution when it restores.

It checks that this packages directory contains the .nupkg and manifest file for the NuGet package and if so it believes the NuGet package is already installed locally.

The message is indicating that the packages are already available in the solution packages directory. Possibly because your build server is not cleaning the existing directory when it checks out the source code and is checking out the source code to the same directory each time.

Ivo answered 17/4, 2015 at 8:20 Comment(4)
We have exactly the same issue but TFS is removing the all the folders before getting the source file to start the build, no packages folders are checked in. Any other ideas?Stouffer
the answer is just explaining the problem but what is the solution ? why it's been marked as answer ??Ative
The solution is to remove the package folders and their contents from the packages directory, then try again.Scuffle
@Scuffle 's answer is the real answer here - additionally, the Visual Studio IDE often behaves counter-intuitively in this scenario: intellisense will display hundreds of errors for missing dependencies, but if you actually attempt to build, the output will succeed even if the 'Errors' pane states otherwiseConger
A
3

I had the same issue.

When I ran nuget restore for sln:

> nuget restore MySolution.sln
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files 
(x86)\MSBuild\14.0\bin'.
All packages listed in packages.config are already installed.

When I ran the restore command individually for each project in solution:

> nuget restore MySolution.Common\packages.config -PackagesDirectory .\packages
Restoring NuGet package Microsoft.Azure.KeyVault.WebKey.3.0.0.
Restoring NuGet package Microsoft.Rest.ClientRuntime.2.3.13.
Restoring NuGet package Microsoft.Azure.KeyVault.3.0.0.
Restoring NuGet package Microsoft.Rest.ClientRuntime.Azure.3.3.15.
Restoring NuGet package NLog.4.5.9.
Restoring NuGet package Autofac.4.8.1.
Restoring NuGet package Microsoft.WindowsAzure.ConfigurationManager.3.2.3.
Restoring NuGet package System.IO.4.3.0.
....

All references are back, and the solution builds correctly after this. Seems like a Nuget bug.

Annelleannemarie answered 12/9, 2018 at 21:38 Comment(0)
I
2

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.

Importance answered 9/11, 2021 at 7:26 Comment(1)
Very strange behavior. After hours of research this answer worked for me. I would have expected a warning about invalid XML in this case. Thank you!Dyson
I
1

NuGet will check the packages directory for the solution when it restores.

It checks that this packages directory contains the .nupkg and manifest file for the NuGet package and if so it believes the NuGet package is already installed locally.

The message is indicating that the packages are already available in the solution packages directory. Possibly because your build server is not cleaning the existing directory when it checks out the source code and is checking out the source code to the same directory each time.

Ivo answered 17/4, 2015 at 8:20 Comment(4)
We have exactly the same issue but TFS is removing the all the folders before getting the source file to start the build, no packages folders are checked in. Any other ideas?Stouffer
the answer is just explaining the problem but what is the solution ? why it's been marked as answer ??Ative
The solution is to remove the package folders and their contents from the packages directory, then try again.Scuffle
@Scuffle 's answer is the real answer here - additionally, the Visual Studio IDE often behaves counter-intuitively in this scenario: intellisense will display hundreds of errors for missing dependencies, but if you actually attempt to build, the output will succeed even if the 'Errors' pane states otherwiseConger

© 2022 - 2024 — McMap. All rights reserved.