Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Package Restore Not Working

Tags:

nuget

Note you can force package restore to execute by running the following commands in the nuget package manager console

Update-Package -Reinstall

Forces re-installation of everything in the solution.


Update-Package -Reinstall -ProjectName myProj

Forces re-installation of everything in the myProj project.

Note: This is the nuclear option. When using this command you may not get the same versions of the packages you have installed and that could be lead to issues. This is less likely to occur at a project level as opposed to the solution level.

You can use the -safe commandline parameter option to constrain upgrades to newer versions with the same Major and Minor version component. This option was added later and resolves some of the issues mentioned in the comments.

Update-Package -Reinstall -Safe


For others who stumble onto this post, read this.

NuGet 2.7+ introduced us to Automatic Package Restore. This is considered to be a much better approach for most applications as it does not tamper with the MSBuild process. Less headaches.

Some links to get you started:

  • The right way to restore NuGet packages
  • Migrate away from MSBuild-based NuGet package restore
  • Migrating MSBuild-Integrated solutions to use Automatic Package Restore

You have to choose one way of the following :

Re-installing a package by it's name in all solution's projects:

Update-Package –reinstall <packageName>

Re-installing a package by it's name and ignoring it's dependencies in all solution's projects:

Update-Package –reinstall <packageName> -ignoreDependencies

Re-installing a package by it's name in a project:

Update-Package –reinstall <packageName> <projectName>

Re-installing all packages in a specific project:

Update-Package -reinstall -ProjectName <projectName>

Re-installing all packages in a solution:

Update-Package -reinstall 

Did you enable package restore mode in the project that has the missing packages/binaries ? There's a known issue that requires the packages to be correctly installed when enabling the restore mode :

http://nuget.codeplex.com/workitem/1879


Original link is dead; this might be a replacement: https://github.com/NuGet/Home/issues/1968


VS 2017

Tools>NuGet Package Manager>Package Manager Settings>General Click on "Clear All NuGet Cache(s)"