Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet: Update a package to a specific version in all projects via PowerShell or CMD

Tags:

We have a scenario, where different teams work on different parts of a larger product. From time to time, all Visual Studio Projects of all Solutions there need to get some of their referenced NuGet packages updated. As a result of that update, all projects in the whole source tree should reference the same versions of the packages.

Is there a way to update a specific NuGet package to a specific version in all projects using some automatic approach like PowerShell scripts?

Edit: Is there a way to somehow load the necessary parts of Visual Studio and NuGet to also update the assembly references correctly?

Example:

NuGetScript Update Solution.sln PackageName -version NewVersion 

or

NuGetScript Update PathToProjects PackageName -version NewVersion 

There are too many components to load all of them in Visual Studio and update them manually via package manager UI.

like image 319
matthias.lukaszek Avatar asked Sep 19 '16 13:09

matthias.lukaszek


People also ask

How do I change NuGet package version?

Right-click the Packages folder in the project, and select Update. This will update the NuGet package to the latest version. You can double-click the Add packages and choose the specific version.


1 Answers

Please use following command line in Package Manager Console window to update a specific package in one solution.

Get-Project -All | Update-Package PackageName -Version newVersion

like image 177
Weiwei Avatar answered Oct 23 '22 00:10

Weiwei