Restoring Nuget References?

maxp picture maxp · Oct 26, 2012 · Viewed 112.6k times · Source

I have solution & project in Visual Studio 2012.

The project has a file packages.config in the root of the project.

For the purposes of this question, lets assume I accidentally removed these libraries from the References section of my project.

When going into NuGet package manager, the interface is still reporting a tick next to these packages, indicating they are installed.

The only way I can see how to fix this situation is to delete all the entries from packages.config, which will fix the issue of the NuGet interface reporting them as installed, and re-add each one.

Is there a smarter way? I had hoped enabling 'enable nuget to restore missing packages' would solve this, but it doesnt seem to do anything.

Answer

jmfenoll picture jmfenoll · Mar 8, 2013

Try re-installing the packages.

In the NuGet Package Manager Console enter the following command:

Update-Package -Reinstall -ProjectName Your.Project.Name

If you want to re-install packages and restore references for the whole solution omit the -ProjectName parameter.