一次更新 nuget 包及其所有依赖项

Updating nuget package and all its dependencies at once

我刚刚用 Angular 项目创建了一个新的 .net 核心,并且已经有一些 NuGet 包,例如 "Microsoft.AspNetCore.SpaServices.Extensions" 有可用的更新。

当我尝试更新它时出现错误,提示与另一个包 "Microsoft.ApNetCore.Mvc.Abstractions" 存在版本冲突,为了解决这个问题,我需要安装或引用 "Microsoft.ApNetCore.Mvc.Abstractions" 2.2。 0,当我尝试安装它时,出现关于另一个依赖项的类似错误等等。

有没有办法让 nuget update/install 一次获得所有这些依赖项,而不是我一个一个地安装它们?

Is there a way to make nuget update/install all of those dependencies at once instead of me installing them one by one?

通过命令行: 类似issue可以下载nuget.exe,and add the path where it exists to Path system environment variables. Then you could simply reference the nuget.exe directly. After that you can use command like nuget update YourSolution.sln in Package Manager Console to update the dependencies for solution. More details see Matt's answer。感谢他!

在 VS IDE:Solution Explorer=>Manage Nuget Packages 中右键单击项目名称,在 Updates实验室你可以选择Select all packagesUpdate按钮。

But one point you may need to know is the update action you've done is not suggested for this situation.

以上是为了回答您有关轻松更新或安装所有依赖项的方法的问题。但实际上您 不应该更新 项目中的 Microsoft.AspNetCore.SpaServices.Extensions 包。您正在开发一个目标为 .net core 2.1 而不是 .net core 2.2 的项目。所以当你新建一个.net core2.1 with Angular project时,这些在模板中设计的nuget包,版本为2.1.X就够了,你不需要更新它们.net core2.2 或更高版本。

你在一个 asp .net core 2.1 项目中,它依赖于 Microsoft.AspNetCore.App 2.1.X,检查它的依赖你可以找到这样的东西:

我认为这就是它抛出 version conflicts 错误消息的原因,那么在这种情况下您更新包的特殊原因是什么?您可以安装 .net core 2.2 SDK here。然后你可以创建针对.net core2.2 的项目,并在你的项目中引用版本为 2.2.x 的那些与 AspNetCore 相关的包。如果我有任何误解,请随时纠正我:)