forked from visualon/dday.ical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.ps1
90 lines (76 loc) · 2.14 KB
/
release.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
param(
[Parameter(Mandatory=$true,Position=0)]
[Alias("t,tgt")]
[ValidateSet('Pack', 'Push')]
[string] $Target,
[Alias("f")]
[switch] $Full,
[Alias("c,cfg")]
[ValidateSet('Debug', 'Release')]
[string] $Configuration = 'Release',
[Alias("v")]
[string] $Version = '',
[string] $id = 'DDay.iCal'
)
#region helper functions
function Invoke-BuildProject
{
Param(
[Parameter(Mandatory=$true)]
[String] $proj,
[String] $tgt = 'Build',
[String] $v = 'm',
[String] $props,
[int] $m = 4
)
$msbuild = Get-MsBuild
$opts = @("$proj", '/nologo', "/t:$tgt", "/m:$m", "/v:$v")
if($props -ne $null -and $props -ne '')
{
$opts += ('/p:' + $props + '')
}
& $msbuild $opts
if(!$?)
{
throw "Build error! See above."
}
}
function Get-MsBuild
{
$msbuilds = @('12.0', '4.0')
foreach($ver in $msbuilds)
{
$r = ('HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\{0}' -f $ver)
if(Test-Path $r)
{
$p = $r | Get-ItemProperty -Name 'MSBuildToolsPath' | Select-Object -ExpandProperty 'MSBuildToolsPath'
return "$p\msbuild.exe"
}
}
throw "MsBuild not found"
}
#endregion
$dir = Split-Path -Parent -Path $MyInvocation.MyCommand.Path
if ($Version -eq '' -or $Version -eq $null) {
$Version = Get-Content (Join-Path $dir Version.txt)
}
if ($Full) {
$Configuration = 'Release'
} else {
$Configuration = 'Debug'
$Version += '-dev-' + (Get-Date (git show -s --format=%ai)).ToUniversalTime().ToString('yyyyMMddHHmmss')
}
switch($Target)
{
'Push'
{
& nuget push ((Join-Path $dir bin) + "\*.$Version.nupkg")
& git push origin v$Version -f
}
'Pack'
{
Invoke-BuildProject -proj build.proj -tgt $Target -props "Configuration=$Configuration;Version=$Version"
& nuget pack DDay.iCal.nuspec -Version $Version -Properties "id=$id;Configuration=$Configuration" -OutputDirectory (Join-Path $dir bin)
& git tag v$Version -f
}
}