Skip to content

Instantly share code, notes, and snippets.

@chaliy
Created December 19, 2010 17:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chaliy/747529 to your computer and use it in GitHub Desktop.
Save chaliy/747529 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 last version
#
# USAGE
# Place this file (Upgrade-Package.ps1) to your solution folder.
# From Package Manager Console execute
#
# .\Upgrade-Package.ps1 -PackageID:Castle.Core
#
# Do not hestitate to contact me at any time
# mike@chaliy.name, http://twitter.com/chaliy
#
# Update to NuGet 1.1 is done by JasonGrundy, see comments bellow
#
##########################################################
param($PackageID)
$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 -eq $PackageID}) {
Update-Package $package.Id -Project:$project.Name
}
}
@syska
Copy link

syska commented Apr 8, 2011

I just read the first line in the description: "Script to upgrade all NuGet packages in solution to last version" and assumed it updated all packages to there latest version I none argument was given on the line.

Yes, Now I know that for sure and I will be looking at both NuGetPackageUpdater and have allready voted on Haacked's blog.

But still thanks very much for this script since it still helped me.

mvh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment