-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrapper.ps1
38 lines (29 loc) · 1.32 KB
/
Bootstrapper.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
param(
[string]$buildScript = "./default.ps1"
)
# Get latest PSAKE version
Write-Host "Getting latest version..."
$latestVersion = Invoke-RestMethod -Uri "https://api.github.com/repos/psake/psake/releases/latest" | Select -ExpandProperty "name"
Write-Host "Latest version is: $latestVersion" -ForegroundColor Green
#Check if we have latest version if not download
$psakeZip = "$PSScriptRoot\$latestVersion.zip"
if (-Not (Test-Path $psakeZip)) {
Write-Host "Downloading psake $latestVersion..."
$downloadUrl = "https://github.com/psake/psake/archive/$latestVersion.zip"
Invoke-WebRequest -Uri $downloadUrl -OutFile $psakeZip
Write-Host "psake $latestVersion downloaded to $PSScriptRoot!" -ForegroundColor Green
}
$archivePath = "psake-" + $latestVersion.TrimStart('v')
#Check if we have the archive extracted if not extract it
if(-Not (Test-Path $archivePath)) {
Write-Host "Extracting archive to $PSScriptRoot..."
Expand-Archive -Path $psakeZip -DestinationPath $PSScriptRoot
Write-Host "Archive unpacked!" -ForegroundColor Green
}
$psakePath = "$archivePath\psake.ps1"
if (-Not (Test-Path $psakePath)) {
throw [System.IO.FileNotFoundException] "$psakePath not found."
}
# Invoke the psake build file
Write-Host "Running Psake build file $buildScript!" -ForegroundColor Green
& $psakePath $buildScript