-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefault.ps1
86 lines (69 loc) · 2.3 KB
/
default.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
properties {
$base_dir = resolve-path .
$src_dir = "$base_dir\ExampleClients\dotnet\UDIR.PAS2.Example.Client\";
$packages_dir = "$src_dir\packages";
$config = 'debug';
$sln = "$src_dir\UDIR.PAS2.Example.Client.sln";
$runsOnBuildServer = $false;
$dist_dir = "$base_dir\dist";
$ant_buildfile = "$base_dir\ExampleClients\java\eksamen\build.xml"
}
Import-module "$psscriptroot\tools\teamcity.psm1" -WarningAction SilentlyContinue
FormatTaskName {
param($taskName)
write-host "Executing Task: $taskName" -foregroundcolor Magenta
}
task -name validate-config -depends add-teamcity-reporting -action {
assert ( 'debug', 'release' -contains $config) "Invalid config: $config. Should be 'debug' or 'release'"
Write-host "Build version is $build_version"
Write-host "Configuration is $config"
Write-host "Running on build server: $runsOnBuildServer"
if (-not(test-path -pathtype container -path $dist_dir)) { md $dist_dir | out-null }
}
task -name add-teamcity-reporting -precondition { return $runsOnBuildServer } -action {
exec {
TaskSetup {
$taskName = $psake.context.Peek().currentTaskName
$global:pasPakkerBuildResult = "##teamcity[buildStatus status='FAILURE' text='Build failed on step $taskName']"
TeamCity-ReportBuildProgress "Running task $taskName"
}
}
}
task -name rebuild -depends clean, build
task -name ensure-nuget -action {
exec {
nuget update -self
}
}
task -name compile_java -action {
exec {
& "$env:ANT_HOME\bin\ant.bat" -f $ant_buildfile
}
}
task -name restore-nuget -depends ensure-nuget -action {
exec {
nuget restore $sln
}
}
task -name build-sln -depends validate-config, restore-nuget -action {
exec {
run-msbuild $sln 'build' $config
}
}
task -name clean -depends validate-config -action {
exec {
run-msbuild $sln 'clean' $config
}
}
task -name ci -depends compile_java,build-sln -action {
exec {
}
}
task build -depends build-sln
task default -depends build-sln
########### Helper functions ########################
function run-msbuild($sln_file, $t, $cfg) {
$v = if ($runsOnBuildServer) { 'n'} else { 'q' }
Framework '4.6.1'
msbuild /nologo /verbosity:$v $sln_file /t:$t /p:Configuration=$cfg /tv:14.0
}