There are some scenarios where you might want to reinstall nuget packages in your projects, like for example:
Project Retargeting or Upgrade
This can be useful when a project has been retargeted or upgraded and if the package REQUIRES reinstallation due to the change in target framework.
You Broke the Project
In case, you have inadvertently modified contents installed from a package and broke your project, you might want to go back to a state where the package contents present in your project match the actual contents of the package.
Package Update Broke the Project
You updated a package and this broke your project. The failure is generally caused by a dependency package which may have gotten updated directly or because of another package update causing a dependency update. All you want to do now is to go back to a state, where the older version of the dependency package where things were fine.
Improved NuGet Package Development cycle
Package authors often need to reinstall the same version of package they are developing to test the behavior. The command `Install-Package` does not provide ‘-force’ option, that could forcefully reinstall a package. So, Update-Package -reinstall is added to meet that requirement.
In order to do so you need to run the following command:
// Will scan all projects in your solution // and reinstall all packages Update-Package -safe -reinstall -IgnoreDependencies // or // Will scan all projects in your solution // and reinstall the specified package Update-Package <PackageName> -safe -reinstall -IgnoreDependencies
This can take some time, based on the number of packages and projects in your solution.