Updating nuget package and all its dependencies at once

I just created a new .net core with Angular project and there are already some NuGet packages like "Microsoft.AspNetCore.SpaServices.Extensions" with updates available.

When I try to update it there is an error that says that there is a version conflict with another package "Microsoft.ApNetCore.Mvc.Abstractions", that to solve this problem i need to install or reference "Microsoft.ApNetCore.Mvc.Abstractions" 2.2.0, when i try to install it then a similar error appears about another dependency and so on.

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


Solution 1:

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

By Command-line: You can download 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 in a similar issue. Thanks to him!

In VS IDE: Right-click project name in Solution Explorer=>Manage Nuget Packages, in Updates lab you can choose Select all packages and Update Button.

enter image description here

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

All above is to answer your question about the way to easily update or install all dependencies. But actually you're not supposed to update the Microsoft.AspNetCore.SpaServices.Extensions package in your project. You're developing a project that targets .net core 2.1 instead of .net core 2.2. So when you create a new .net core2.1 with Angular project, these nuget packages designed in the template whose version is 2.1.X is enough, you don't need to update them to .net core2.2 or higher.

You're in a asp .net core 2.1 project, and it depends on Microsoft.AspNetCore.App 2.1.X, check its dependencies you can find something like this:

enter image description here

I think that's why it threw version conflicts error message, so what's the special reason you update the package in this situation? You can install .net core 2.2 SDK here. And then you can create the project that targets .net core2.2 and reference those AspNetCore-related packages with version 2.2.x in your project. If I misunderstand anything, please feel free to correct me:)