Created
June 6, 2011 04:09
-
-
Save staxmanade/1009729 to your computer and use it in GitHub Desktop.
Powershell function that returns the last version of a NuGet package
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
function Get-Last-NuGet-Version($nuGetPackageId) { | |
$feeedUrl = "http://packages.nuget.org/v1/FeedService.svc/Packages()?`$filter=Id%20eq%20'$nuGetPackageId'" | |
$webClient = new-object System.Net.WebClient | |
$queryResults = [xml]($webClient.DownloadString($feeedUrl)) | |
$version = $queryResults.feed.entry | %{ $_.properties.version } | sort-object | select -last 1 | |
if(!$version){ | |
$version = "0.0" | |
} | |
$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
function Increment-Version($version){ | |
$parts = $version.split('.') | |
for($i = $parts.length-1; $i -ge 0; $i--){ | |
$x = ([int]$parts[$i]) + 1 | |
if($i -ne 0) { | |
# Don't roll the previous minor or ref past 10 | |
if($x -eq 10) { | |
$parts[$i] = "0" | |
continue | |
} | |
} | |
$parts[$i] = $x.ToString() | |
break; | |
} | |
[System.String]::Join(".", $parts) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment