forked from jonwagner/EventSourceProxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuild.psake.ps1
More file actions
88 lines (71 loc) · 2.33 KB
/
Build.psake.ps1
File metadata and controls
88 lines (71 loc) · 2.33 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
$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"
$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
function Replace-Version {
param (
[string] $Path
)
(Get-Content $Path) |
% { $_ -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 Build {
ReplaceVersions
try {
# build the NET45 binaries
Exec {
Invoke-Expression "$msbuild $baseDir\EventSourceProxy.sln '/p:Configuration=$configuration' '/t:Clean;Build'"
}
}
finally {
RestoreVersions
}
}
Task Test -depends Build {
Exec {
Invoke-Expression "$nunit $baseDir\EventSourceProxy.Tests\bin\$configuration\EventSourceProxy.Tests.dll"
Invoke-Expression "$nunit $baseDir\EventSourceProxy.Tests.NuGet\bin\$configuration\EventSourceProxy.Tests.NuGet.dll"
}
}
Task Package -depends Test {
Wipe-Folder $outputDir
# package nuget
Exec {
Invoke-Expression "$nuget pack $baseDir\EventSourceProxy.nuspec -OutputDirectory $outputDir -Version $version -NoPackageAnalysis"
}
# package nuget
Exec {
Invoke-Expression "$nuget pack $baseDir\EventSourceProxy.NuGet.nuspec -OutputDirectory $outputDir -Version $version -NoPackageAnalysis"
}
}