-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
build.ps1
49 lines (42 loc) · 1.48 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
# Parses and validates the command arguments and bootstraps the Psake build script with the cleaned values
function Get-NextArg([string[]]$arguments, [int]$i, [string]$argName) {
$i++
if ($arguments.Length -gt $i -and -not $($arguments[$i]).StartsWith('-')) {
return $arguments[$i]
} else {
throw $("'$argName' requires a value to be passed as the next argument")
}
}
[string]$packageVersion = ''
[string]$fileVersion = ''
[string]$configuration = 'Release'
[bool]$runTests = $false
for ([int]$i = 0; $i -lt $args.Length; $i++) {
$arg = $args[$i]
$loweredArg = "$arg".ToLowerInvariant()
if ($loweredArg -eq '-t' -or $loweredArg -eq '--test') {
$runTests = $true
} elseif ($loweredArg -eq '-config' -or $loweredArg -eq '--configuration') {
$configuration = Get-NextArg $args $i $arg
$i++
} else {
throw $("Unrecognized argument: '$arg'")
}
}
[string[]]$task = 'Pack'
if ($runTests) {
$task = 'Pack','Test'
}
$parameters = @{}
$properties = @{}
if (-not [string]::IsNullOrWhiteSpace($packageVersion)) {
$properties.packageVersion=$packageVersion
}
if (-not [string]::IsNullOrWhiteSpace($fileVersion)) {
$properties.fileVersion=$fileVersion
}
if (-not [string]::IsNullOrWhiteSpace($configuration)) {
$properties.configuration=$configuration
}
Import-Module "$PSScriptRoot/.build/psake/psake.psm1"
Invoke-Psake "$PSScriptRoot/.build/runbuild.ps1" -task $task -properties $properties -parameters $parameters