-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
75 lines (72 loc) · 2.32 KB
/
Copy pathbuild.ps1
File metadata and controls
75 lines (72 loc) · 2.32 KB
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
$CakeVersion = "0.25.0"
$IsRunningOnUnix = [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Unix
# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
$ToolPath = Join-Path $PSScriptRoot "tools"
if (!(Test-Path $ToolPath)) {
Write-Verbose "Creating tools directory..."
New-Item -Path $ToolPath -Type directory | out-null
}
###########################################################################
# INSTALL CAKE
###########################################################################
if (-not (Get-Command Expand-Archive -ErrorAction SilentlyContinue))
{
if ($PSVersionTable.PSVersion.Major -le 3)
{
& {
function global:Expand-Archive
{
param([string]$Path, [string]$DestinationPath)
$shell = New-Object -com shell.application
$zip = $shell.NameSpace($Path)
foreach($item in $zip.items())
{
$shell.Namespace($DestinationPath).copyhere($item)
}
}
}
}
else
{
& {
Add-Type -AssemblyName System.IO.Compression.FileSystem
function global:Expand-Archive
{
param([string]$Path, [string]$DestinationPath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($Path, $DestinationPath)
}
}
}
}
# Make sure Cake has been installed.
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion"
$CakeExePath = Join-Path $CakePath "Cake.exe"
$CakeZipPath = Join-Path $ToolPath "Cake.zip"
$CakeUri = "https://www.nuget.org/api/v2/package/Cake/$CakeVersion"
if (!(Test-Path $CakeExePath)) {
Write-Host "Installing Cake $CakeVersion..."
(New-Object System.Net.WebClient).DownloadFile($CakeUri, $CakeZipPath)
Expand-Archive $CakeZipPath $CakePath
Remove-Item $CakeZipPath
}
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
if ($IsRunningOnUnix)
{
& mono "$CakeExePath" --bootstrap
if ($LASTEXITCODE -eq 0)
{
& mono "$CakeExePath" $args
}
}
else
{
& "$CakeExePath" --bootstrap
if ($LASTEXITCODE -eq 0)
{
& "$CakeExePath" $args
}
}
exit $LASTEXITCODE