-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathBuild.psake.ps1
More file actions
113 lines (92 loc) · 3.09 KB
/
Build.psake.ps1
File metadata and controls
113 lines (92 loc) · 3.09 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
$psake.use_exit_on_error = $true
#########################################
# to build a new version
# 1. git tag 1.0.x
# 2. build package
#########################################
properties {
$baseDir = $psake.build_script_dir
$version = git describe --abbrev=0 --tags
$changeset = (git log -1 $version --pretty=format:%H)
$assemblyversion = $version.Split('-', 2)[0]
$outputDir = "$baseDir\Build\Output"
$net40Path = "$baseDir\Insight.Database.Schema\bin\NET40"
$framework = "$env:systemroot\Microsoft.NET\Framework\v4.0.30319\"
$msbuild = $framework + "msbuild.exe"
$configuration = "Release"
$nuget = "nuget.exe"
$nunit = Get-ChildItem "$baseDir\packages" -Recurse -Include nunit-console.exe
}
Task default -depends Build
Task Build -depends Build40,Build45
Task Test -depends Test40,Test45
function Replace-Version {
param (
[string] $Path
)
(Get-Content $Path) |
% { $_ -replace "\[assembly: AssemblyVersion\(`"(\d+\.?)*`"\)\]","[assembly: AssemblyVersion(`"$assemblyversion`")]" } |
% { $_ -replace "\[assembly: AssemblyFileVersion\(`"(\d+\.?)*`"\)\]","[assembly: AssemblyFileVersion(`"$assemblyversion`")]" } |
Set-Content $Path
}
function ReplaceVersions {
Get-ChildItem $baseDir -Include AssemblyInfo.cs -Recurse |% { Replace-Version $_.FullName }
}
function RestoreVersions {
Get-ChildItem $baseDir -Include AssemblyInfo.cs -Recurse |% {
git checkout $_.FullName
}
}
function Wipe-Folder {
param (
[string] $Path
)
if (Test-Path $Path) { Remove-Item $Path -Recurse }
New-Item -Path $Path -ItemType Directory | Out-Null
}
Task Build40 {
ReplaceVersions
try {
# build the NET40 binaries
Exec {
Invoke-Expression "$msbuild $baseDir\Insight.sln /p:Configuration=$configuration /p:TargetFrameworkVersion=v4.0 /p:DefineConstants=```"NODBASYNC``;CODE_ANALYSIS```" '/t:Clean;Build'"
}
# copy the binaries to the net40 folder
Wipe-Folder $net40Path
Copy-Item $baseDir\Insight.Database.Schema\bin\Release\*.* $net40Path
Copy-Item $baseDir\Insight.Database.Schema.Tests\bin\Release\*.* $net40Path
Copy-Item $baseDir\Insight.Database.Schema.Installer\bin\Release\*.* $net40Path
}
finally {
RestoreVersions
}
}
Task Build45 {
ReplaceVersions
try {
# build the NET45 binaries
Exec {
Invoke-Expression "$msbuild $baseDir\Insight.sln '/p:Configuration=$configuration' '/t:Clean;Build'"
}
}
finally {
RestoreVersions
}
}
Task Test40 -depends Build40 {
Exec {
Invoke-Expression "$nunit $net40Path\Insight.Database.Schema.Tests.dll"
}
}
Task Test45 -depends Build45 {
Exec {
Invoke-Expression "$nunit $baseDir\Insight.Database.Schema.Tests\bin\$configuration\Insight.Database.Schema.Tests.dll"
}
}
Task Package -depends Test {
Wipe-Folder $outputDir
# package nuget
Exec {
Invoke-Expression "$nuget pack $baseDir\Insight.Database.Schema.nuspec -OutputDirectory $outputDir -Version $version -NoPackageAnalysis"
}
}