-
Notifications
You must be signed in to change notification settings - Fork 8
/
NuGet.Pack.Extensions.ps1
59 lines (48 loc) · 2.08 KB
/
NuGet.Pack.Extensions.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
$proxy = New-Object System.Net.WebProxy($global:ProxyUrl, $global:ProxyPort)
$proxy.Credentials = (Get-Credential).GetNetworkCredential()
$webclient.Proxy = $proxy
$queryResults = [xml]($webClient.DownloadString($feeedUrl))
$queryResults.feed.entry | %{ $_.properties.version } | sort-object | select -last 1
}
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)
}
$version = Get-Last-NuGet-Version 'EventAggregator.Net.Extensions'
if(!$version){
$version = "0.0"
}
$newVersion = Increment-Version $version
$nuget = ls .\packages\NuGet.CommandLine*\tools\NuGet.exe
$buildRoot = ".\NuGetBuild.Extensions"
$eventAggregatorDestination = "$buildRoot\content\Events"
rm $buildRoot -force -recurse -ErrorAction SilentlyContinue
mkdir $eventAggregatorDestination | out-null
cp .\EventAggregator\EventAggregatorExtensions.cs (Join-Path $eventAggregatorDestination "EventAggregatorExtensions.cs.pp")
$eaFile = Join-Path $eventAggregatorDestination EventAggregatorExtensions.cs.pp
(Get-Content $eaFile) |
Foreach-Object { $_ -replace 'namespace EventAggregatorNet', 'namespace $rootnamespace$.Events' } |
Set-Content $eaFile
$nuspecFile = "EventAggregator.Net.Extensions.$newVersion.nuspec"
cp .\EventAggregator.Net.Extensions.nuspec "$buildRoot\$nuspecFile"
pushd $buildRoot
$nuspec = [xml](cat $nuspecFile)
$nuspec.package.metadata.version = $newVersion
$nuspec.Save((get-item $nuspecFile))
& $nuget pack $nuspecFile
popd