forked from KSP-CKAN/CKAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
62 lines (52 loc) · 1.85 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
Param (
[Parameter(Position = 0)]
[string]$Arg0,
[Parameter(ValueFromRemainingArguments = $true)]
[Object[]]$RemainingArgs
)
# PSScriptRoot isn't set in PowerShell 2
$minPSVer = [version]"3.0"
if (($PSVersionTable.PSVersion -lt $minPSVer)) {
[Console]::ForegroundColor = 'red'
[Console]::Error.WriteLine("This script does not support PowerShell $($PSVersionTable.PSVersion).")
[Console]::Error.WriteLine("Please upgrade to PowerShell $minPSVer or later.")
[Console]::ResetColor()
exit
}
# Globals
$NugetVersion = "4.4.0"
$UseExperimental = $false
$RootDir = "${PSScriptRoot}"
$ScriptFile = "${RootDir}/build.cake"
$BuildDir = "${RootDir}/_build"
$ToolsDir = "${BuildDir}/tools"
$PackagesDir = "${BuildDir}/lib/nuget"
$NugetExe = "${ToolsDir}/NuGet/${NugetVersion}/nuget.exe"
$PackagesConfigFile = "${RootDir}/packages.config"
$CakeVersion = (Select-Xml -Xml ([xml](Get-Content $PackagesConfigFile)) -XPath "//package[@id='Cake'][1]/@version").Node.Value
$CakeExe = "${PackagesDir}/Cake.${CakeVersion}/Cake.exe"
# Download NuGet
$NugetDir = Split-Path "$NugetExe" -Parent
if (!(Test-Path "$NugetDir")) {
mkdir $nugetDir > $null
}
if (!(Test-Path "$NugetExe")) {
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/v${NugetVersion}/nuget.exe", $NugetExe)
}
# Install build packages
Invoke-Expression "& '${NugetExe}' restore `"${PackagesConfigFile}`" -OutputDirectory `"${PackagesDir}`""
# Build args
$cakeArgs = @()
if ($Arg0) {
if ($Arg0[0] -eq "-") {
$cakeArgs += "${Arg0}"
} else {
$cakeArgs += "--target=${Arg0}"
}
}
if ($UseExperimental) {
$cakeArgs += "--experimental"
}
# Run Cake
Invoke-Expression "& '${CakeExe}' '${ScriptFile}' ${cakeArgs} ${RemainingArgs}"
exit $LASTEXITCODE