forked from akurdyukov/NCrash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
98 lines (74 loc) · 3.61 KB
/
build.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
91
92
93
94
95
96
97
98
properties {
$ProductName = "NCrash"
$BaseDir = Resolve-Path "."
$SolutionFile = "$BaseDir\$ProductName.sln"
$OutputDir = "$BaseDir\Deploy\Package\"
# Gets the number of commits since the last tag.
$Version = "1.0." + (git describe --tags --long).split('-')[1]
$BuildConfiguration = "Release"
$NuGetPackageName = "NCrash"
$NuGetWinFormsPackageName = "NCrash.WinForms"
$NuGetWPFPackageName = "NCrash.WPF"
$NuGetPackDir = "$OutputDir" + "Pack"
$NuGetPackWinFormsDir = "$OutputDir" + "PackWinForms"
$NuGetPackWPFDir = "$OutputDir" + "PackWPF"
$NuSpecFileName = "NCrash.nuspec"
$NuSpecWinFormsFileName = "NCrash.WinForms.nuspec"
$NuSpecWPFFileName = "NCrash.WPF.nuspec"
$NuGetPackagePath = "$OutputDir" + $NuGetPackageName + "." + $Version + ".nupkg"
$NuGetWinFormsPackagePath = "$OutputDir" + $NuGetWinFormsPackageName + "." + $Version + ".nupkg"
$NuGetWPFPackagePath = "$OutputDir" + $NuGetWPFPackageName + "." + $Version + ".nupkg"
$ArchiveDir = "$OutputDir" + "Archive"
}
Framework '4.0'
task default -depends Pack
task Init {
}
task Clean -depends Init {
if (Test-Path $OutputDir) {
ri $OutputDir -Recurse
}
ri "$NuGetPackageName.*.nupkg"
ri "$NuGetPackageName.zip" -ea SilentlyContinue
}
task Build -depends Init,Clean {
exec { msbuild $SolutionFile "/p:OutDir=$OutputDir" "/p:Configuration=$BuildConfiguration" }
}
task Pack -depends Build {
# Pack main dll
mkdir $NuGetPackDir
cp "$NuSpecFileName" "$NuGetPackDir"
mkdir "$NuGetPackDir\lib\net40"
cp "$OutputDir\$ProductName.dll" "$NuGetPackDir\lib\net40"
$Spec = [xml](get-content "$NuGetPackDir\$NuSpecFileName")
$Spec.package.metadata.version = ([string]$Spec.package.metadata.version).Replace("{Version}",$Version)
$Spec.Save("$NuGetPackDir\$NuSpecFileName")
exec { .\.nuget\nuget pack "$NuGetPackDir\$NuSpecFileName" -OutputDirectory "$OutputDir" }
# Pack WinForms dll
mkdir $NuGetPackWinFormsDir
cp "$NuSpecWinFormsFileName" "$NuGetPackWinFormsDir"
mkdir "$NuGetPackWinFormsDir\lib\net40"
cp "$OutputDir\$NuGetWinFormsPackageName.dll" "$NuGetPackWinFormsDir\lib\net40"
$Spec = [xml](get-content "$NuGetPackWinFormsDir\$NuSpecWinFormsFileName")
$DependObj = $Spec.package.metadata.dependencies.dependency | ? { $_.id -eq "NCrash" }
$DependObj.SetAttribute("version", ($DependObj.version).Replace("{Version}",$Version))
$Spec.package.metadata.version = ([string]$Spec.package.metadata.version).Replace("{Version}",$Version)
$Spec.Save("$NuGetPackWinFormsDir\$NuSpecWinFormsFileName")
exec { .\.nuget\nuget pack "$NuGetPackWinFormsDir\$NuSpecWinFormsFileName" -OutputDirectory "$OutputDir" }
# Pack WPF dll
mkdir $NuGetPackWPFDir
cp "$NuSpecWPFFileName" "$NuGetPackWPFDir"
mkdir "$NuGetPackWPFDir\lib\net40"
cp "$OutputDir\$NuGetWPFPackageName.dll" "$NuGetPackWPFDir\lib\net40"
$Spec = [xml](get-content "$NuGetPackWPFDir\$NuSpecWPFFileName")
$DependObj = $Spec.package.metadata.dependencies.dependency | ? { $_.id -eq "NCrash" }
$DependObj.SetAttribute("version", ($DependObj.version).Replace("{Version}",$Version))
$Spec.package.metadata.version = ([string]$Spec.package.metadata.version).Replace("{Version}",$Version)
$Spec.Save("$NuGetPackWPFDir\$NuSpecWPFFileName")
exec { .\.nuget\nuget pack "$NuGetPackWPFDir\$NuSpecWPFFileName" -OutputDirectory "$OutputDir" }
}
task Publish -depends Pack {
exec { .\.nuget\nuget push $NuGetPackagePath }
exec { .\.nuget\nuget push $NuGetWinFormsPackagePath }
exec { .\.nuget\nuget push $NuGetWPFPackagePath }
}