I'm trying to update all NuGet packages for a solution in VS Code (using Mac). Is there a way to achieve that in VS code or for a specific project.json file? At the moment I'm going one by one but I would have thought there is either an extension or a feature that does that for you?
NuGet installs the latest version of the package when you use the dotnet add package command unless you specify the package version ( -v switch).
For Update all packages in all projects nuget package manager gui extension can do it with one click.
How it works
Load Package Versions
Update All Packages
Based on Jon Canning's powershell solution. I fixed a small bug where only the first dependency was being updated and not all the dependencies for the project file.
$regex = 'PackageReference Include="([^"]*)" Version="([^"]*)"' ForEach ($file in get-childitem . -recurse | where {$_.extension -like "*proj"}) { $packages = Get-Content $file.FullName | select-string -pattern $regex -AllMatches | ForEach-Object {$_.Matches} | ForEach-Object {$_.Groups[1].Value.ToString()}| sort -Unique ForEach ($package in $packages) { write-host "Update $file package :$package" -foreground 'magenta' $fullName = $file.FullName iex "dotnet add $fullName package $package" } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With