-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
84 lines (71 loc) · 2.29 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
<#
.SYNOPSIS
A psake bootstraper; This script runs one or more tasks defined in the psake file.
.EXAMPLE
.\build.ps1 -Help;
This example prints a list of all the available tasks.
#>
Param(
[Alias('t')]
[string[]]$Tasks = @("default"),
[Alias('s', "keys")]
[hashtable]$Secrets = @{},
[Alias('c')]
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[Alias("sc", "no-build")]
[switch]$SkipCompilation,
[Alias('h', '?')]
[switch]$Help,
[Alias('no-commit')]
[switch]$NoCommit,
[string]$TaskFile = "$PSScriptRoot/build/tasks.psake.ps1",
[switch]$SkipClean,
[switch]$Debug,
[switch]$Major,
[switch]$Minor
)
if ($Debug) { $Configuration = "Debug"; }
# Getting the current branch of source control.
$branchName = $env:BUILD_SOURCEBRANCHNAME;
if ([string]::IsNullOrEmpty($branchName))
{
$match = [Regex]::Match((& git branch), '\*\s*(?<name>\w+)');
if ($match.Success) { $branchName = $match.Groups["name"].Value; }
}
# Installing then invoking the Psake tasks.
$toolsDir = "$PSScriptRoot/tools";
$psakeModule = Join-Path $toolsDir "psake/*/*.psd1";
if (-not (Test-Path $psakeModule))
{
if (-not (Test-Path $toolsDir)) { New-Item $toolsDir -ItemType Directory | Out-Null; }
Save-Module "psake" -Path $toolsDir;
}
Import-Module $psakeModule -Force;
if ($Help)
{
Invoke-Psake -buildFile $TaskFile -docs;
}
else
{
Write-Host -ForegroundColor DarkGray "OS: $([Environment]::OSVersion.Platform)";
Write-Host -ForegroundColor DarkGray "User: $([Environment]::UserName)@$([Environment]::MachineName)";
Write-Host -ForegroundColor DarkGray "Branch: $branchName";
Write-Host -ForegroundColor DarkGray "Configuration: $Configuration | $Platform";
Invoke-psake $taskFile -nologo -taskList $Tasks -properties @{
"Secrets"=$Secrets;
"Branch"=$branchName;
"ToolsDir"=$toolsDir;
"RootDir"=$PSScriptRoot;
"Major"=$Major.IsPresent;
"Minor"=$Minor.IsPresent;
"Debug"=$Debug.IsPresent;
"Configuration"=$Configuration;
"SkipClean"=$SkipClean.IsPresent;
"Commit"=(-not $NoCommit.IsPresent);
"TempDir"=([System.IO.Path]::GetTempPath());
"SkipCompilation"=$SkipCompilation.IsPresent;
"SolutionName"=(Split-Path $PSScriptRoot -Leaf);
}
if (-not $psake.build_success) { exit 1; }
}