Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet package restore not working from .nuget\packages.config

Tags:

nuget

I have a project, which uses Chutzpah to run unit tests, however the project does not use Chutzpah any other way, it only uses its command line interface. When I installed the Chutzpah NuGet package, the reference was added to .nuget\packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Chutzpah" version="2.4.3" />
</packages>

I have package restore enabled for this project and the build successfully restores all other used packages but not Chutzpah. I assume it has to do with the fact, that the package reference is located in .nuget\packages.config and not in a project packages.config file, but I don't know why this happened and what is the correct way to work with this?

The Chutzpah NuGet package was added to the project via Visual Studio to a specific project.

To work around the issue I moved the package reference to a project packages.config file and the restore works fine.

like image 602
Tomas Chlouba Avatar asked Jul 19 '13 15:07

Tomas Chlouba


People also ask

How do I force a NuGet package to restore?

Restore NuGet packagesNavigate to Tools > Options > NuGet Package Manager > General, and then select the Allow NuGet to download missing packages check box under Package Restore. Enabling Restore NuGet Packages. In Solution Explorer, right-click the solution, and then select Restore NuGet Packages.

How do I enable NuGet package restore in Visual Studio?

In Visual Studio on Windows, you can restore packages automatically or manually. First, configure Package Restore through Tools > Options > NuGet Package Manager.

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.


1 Answers

Package Restore will not automatically restore solution-level packages. You will need to add a build step to get NuGet to restore the solution packages. For example:

.nuget/nuget.exe install .nuget/packages.config -o packages

For more information see this post on solution level packages.

like image 72
Shamozzle Avatar answered Nov 07 '22 05:11

Shamozzle