Skip to content

Instantly share code, notes, and snippets.

@jchadwick
Forked from chaliy/Upgrade-Package.ps1
Created July 14, 2011 14:29
Show Gist options
  • Save jchadwick/1082558 to your computer and use it in GitHub Desktop.
Save jchadwick/1082558 to your computer and use it in GitHub Desktop.
Script to upgrade all NuGet packages in solution to new version
###########################################################
#
# 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