-
-
Save jchadwick/1082558 to your computer and use it in GitHub Desktop.
Script to upgrade all NuGet packages in solution to new version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################### | |
# | |
# Script to upgrade all NuGet packages in solution to latest version | |
# https://gist.github.com/1082558 | |
# | |
# USAGE | |
# Place this file (Upgrade-Packages.ps1) to your solution folder. | |
# From Package Manager Console execute | |
# | |
# .\Upgrade-Packages.ps1 -PackageFilter:Castle.* | |
# or | |
# .\Upgrade-Packages.ps1 Castle.* | |
# or just | |
# .\Upgrade-Packages.ps1 | |
# to upgrade all NuGet packages in the solution | |
# | |
########################################################## | |
param($PackageFilter = "*") | |
$packageManager = $host.PrivateData.packageManagerFactory.CreatePackageManager() | |
foreach ($project in Get-Project -all) { | |
$fileSystem = New-Object NuGet.PhysicalFileSystem($project.Properties.Item("FullPath").Value) | |
$repo = New-Object NuGet.PackageReferenceRepository($fileSystem, $packageManager.LocalRepository) | |
foreach ($package in $repo.GetPackages() | ? {$_.Id -like $PackageFilter}) { | |
Update-Package $package.Id -Project:$project.Name | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment