forked from OctopusDeploy/OctoPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
102 lines (82 loc) · 2.91 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
99
100
101
102
## This is the OctoPack build script, written in PSAKE. Run with
##
## Import-Module .\tools\psake\psake.psm1
## Invoke-psake .\build.ps1
##
Framework "4.5.1"
properties {
$configuration = "Release"
$nuget_path = ".\source\build\nuget.exe"
$gitversion_exe = ".\tools\GitVersion\GitVersion.exe"
$gitversion_remote_username = $ENV:GITVERSION_REMOTE_USERNAME
$gitversion_remote_password = $ENV:GITVERSION_REMOTE_PASSWORD
}
task default -depends VerifyProperties, Package
task Clean {
write-host "Clean"
$directories = ".\build"
$directories | ForEach-Object {
Write-Output "Clean directory $_"
Remove-Item $_ -Force -Recurse -ErrorAction Ignore
New-Item -Path $_ -ItemType Directory -Force
}
}
task RunGitVersion {
exec {
# Log the current status, branch and latest log to help when things get confused...
Write-Host "Executing 'git status'"
& git status | Write-Host
Write-Host "Executing 'git log -n 1'"
& git log -n 1 | Write-Host
if ($gitversion_remote_username) {
$output = . $gitversion_exe /u "$gitversion_remote_username" /p "$gitversion_remote_password"
} else {
$output = . $gitversion_exe
}
$formattedOutput = $output -join "`n"
Write-Host "Output from gitversion.exe"
Write-Host $formattedOutput
$versionInfo = $formattedOutput | ConvertFrom-Json
$script:package_version = $versionInfo.NuGetVersion
write-host "Package version: $script:package_version"
if ($env:TEAMCITY_VERSION) {
TeamCity-SetBuildNumber $versionInfo.FullSemVer
write-host "TeamCity version: " + $versionInfo.FullSemVer
}
}
}
task Build -depends Clean, RunGitVersion {
write-host "Build"
exec {
msbuild .\source\OctoPack.sln /p:Configuration=$configuration /t:Rebuild
}
}
task Package -depends Build {
write-host "Package"
mkdir .\build\content
mkdir .\build\content\net35
mkdir .\build\content\net40
mkdir .\build\content\netcore45
mkdir .\build\build
mkdir .\build\content\portable-net4+sl50+netcore45+wpa81+wp8
mkdir .\build\tools
dir -recurse .\source\OctoPack.Tasks\bin\$configuration | copy -destination build\build -Force
dir -recurse .\source\build | copy -destination build\build -Force
dir -recurse .\source\tools | copy -destination build\tools -Force
Copy-Item .\source\OctoPack.nuspec .\build
Copy-Item .\license.txt .\build
$base = (resolve-path "build")
write-host $base
exec {
& $nuget_path pack build\OctoPack.nuspec -basepath $base -outputdirectory $base -version $script:package_version -NoPackageAnalysis
}
}
## Helpers
task VerifyProperties {
}
Import-Module .\tools\psake\teamcity.psm1
TaskSetup {
if ($env:TEAMCITY_VERSION) {
TeamCity-ReportBuildProgress "Running task $($psake.context.Peek().currentTaskName)"
}
}