Nuget 包还原异常解决方案

Nuget 包还原异常解决方案

Intro

有时候 nuget 包会还原异常,查看引用好多包都带着感叹号

Solution

打开 Package Manager Console ,选择有问题的项目 Project, 在 Package Manager Console 执行以下命令:

Update-Package -Reinstall

或者

Update-Package -Reinstall -Safe

这样就会重新安装包,并且有更新的还会安装更新,相对来说下面这种方式更好一些,避免出现更新之后有不兼容的类库导致代码编译失败。

原文:

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

Reference

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章