-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathbuild.ps1
48 lines (39 loc) · 1.63 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
$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true'
$ToolPath = Join-Path $PSScriptRoot "tools"
$NugetPath = Join-Path $ToolPath "nuget.exe"
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$CakeVersion = "0.30.0"
# Make sure tools folder exists
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
if (!(Test-Path $ToolPath)) {
Write-Verbose "Creating tools directory..."
New-Item -Path $ToolPath -Type directory | out-null
}
# Try download NuGet.exe if not exists
if (!(Test-Path $NugetPath)) {
Write-Verbose -Message "Downloading NuGet.exe..."
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath)
}
###########################################################################
# INSTALL CAKE
###########################################################################
Add-Type -AssemblyName System.IO.Compression.FileSystem
Function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
# Make sure Cake has been installed.
$NugetFeed = 'https://www.myget.org/F/cake/api/v2/package'
$CakePath = Join-Path $ToolPath "cake.$CakeVersion/Cake.exe"
if (!(Test-Path $CakePath)) {
Write-Host "Installing Cake..."
(New-Object System.Net.WebClient).DownloadFile("$NugetFeed/Cake/$CakeVersion", "$ToolPath\Cake.zip")
Unzip "$ToolPath\Cake.zip" "$ToolPath/cake.$CakeVersion"
Remove-Item "$ToolPath\Cake.zip"
}
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
&"$CakePath" $args
exit $LASTEXITCODE