Created
December 19, 2010 17:59
-
-
Save chaliy/747529 to your computer and use it in GitHub Desktop.
Script to upgrade all NuGet packages in solution to new version
This file contains hidden or 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 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 | |
# [email protected], 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 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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