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

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


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


You can create a PowerShell script to search all the project files or packages.config files in your solution and then call nuget update command to update the packages.

However, there is a limitation when update packages outside of Visual Studio, I would recommend you to do this from Visual Studio:

The update command will download and extract all new packages to the packages folders. Assembly references will be updated in the project file, however this is limited to only existing references. If a new package has an added assembly it will not be added as part of the update command. New package dependencies will also not have their assembly references added. To perform a complete update use Visual Studio.


The following script was found somewhere else. I have tried it with my projects. I don't have the original link

The following script does:

  1. run restore command on any solutions found within a folder
  2. Finds all packages.config files containing the package id name provided
  3. runs update command using the packages.config file and the package name as parameters

This assumes that nuget.exe is present in the folder where you will be running this from

param(    [Parameter(Mandatory=$true)]    [string]$packageId)Get-ChildItem *.sln -recurse | %{.\\nuget.exe restore $_.fullname}Get-ChildItem packages.config -Recurse `  | Where-Object {$_ | Select-String -Pattern $packageId} `  | %{.\\nuget.exe update -Id $packageId $_.FullName}