Abhijeet
Abhijeet

Reputation: 13916

How to Update All Packages of solution to Latest Minor Version Nuget?

Stick together with minor versions of updated packages, in the entire solution.

Ideally Update-Package should do but that command will pick up latest version of all packages, no matter what.

EDIT: I'm hopeful that there exists a switch, so that we don't have to type in specific versions of all packages one by one, NPM, where are you, can you manage DLLs as well ;-)

Upvotes: 24

Views: 15753

Answers (7)

Dejan
Dejan

Reputation: 10373

UPDATE NOV 2020

According to Scott Hanselman, dotnet outdated is outdated. Long live the dotnet-outdated-tool!

dotnet tool install --global dotnet-outdated-tool
dotnet outdated --version-lock major --upgrade

Original Answer

I managed to upgrade all my packages to their latest minor version by using the dotnet-outdated global tool like this:

dotnet tool install --global dotnet-outdated
dotnet outdated --version-lock major --upgrade

It upgraded all the packages in that folder without any problems of intermediary downgrade errors.

Upvotes: 25

Wael Rabadi
Wael Rabadi

Reputation: 1

On the command line using PowerShell

([xml] (Get-Content -Path ./NameOfProject.csproj)).Project.ItemGroup[0].PackageReference.Include | %{ dotnet add ./NameOfProject.csproj package $_ }

Upvotes: 0

Lukasz Mk
Lukasz Mk

Reputation: 7360

Command you are looking for is:

Update-Package -ToHighestMinor

Above command is available only within the NuGet Package Manager Console in Visual Studio (and PowerShell) on Windows.

There is other similar command (which which works in both VS and CLI):

Update-Package -ToHighestPatch

nuget update -safe

Please note the difference - first command will upgrade to highest Minor, but second and third commands will upgrade only to highest Patch.

Also take a look on -DependencyVersion [Lowest, HighestPatch, HighestMinor, Highest, Ignore] parameter, might be useful in some cases.

More details:

Upvotes: 8

Sudara
Sudara

Reputation: 5039

While searching on this I found an open source dotnet tool which can update nuget packages on both .NET framework and .NET Core. https://github.com/NuKeeperDotNet/NuKeeper

You need to install the package with dotnet tool install nukeeper --global and then simply use nukeeper update. It can also automatically create PR if you use it in your CI environment

Upvotes: 1

Paul51
Paul51

Reputation: 39

Check out nukeeper to help out achieve this https://github.com/NuKeeperDotNet/NuKeeper

Upvotes: 1

MindSwipe
MindSwipe

Reputation: 7960

Using Visual Studio, this is trivially easy.

Right click on your Solution file (or project depending on which you want to update) and select "Manage NuGet Packages...". From there switch over to the "Updates" tab select the checkbox where it says "Select all packages" and then click "Update". This will update all packages to their latest stable release, including minor version (e.g 'v4.5.1 -> v4.5.3')

Manage NuGet Packages

Manage NuGet packages

Navigate to Updates Tab

Navigate to Updates

Select all packages

Select all packages

And finally update all packages

Update

Upvotes: -5

Apington
Apington

Reputation: 1

You should be able to use something like Install-Package Microsoft.AspNetCore.Mvc -Version 2.2.0 as described here microsoft docu

for multiple packages you can easily connect multiple calls by ';' as mentioned in an old answer

Upvotes: -2

Related Questions