Skip to content

Commit c8f363c

Browse files
committed
Updated to Cake 0.25.0
* PowerShell core bootstrapper support
1 parent 1e6b63e commit c8f363c

2 files changed

Lines changed: 65 additions & 34 deletions

File tree

build.ps1

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
$CakeVersion = "0.24.0"
1+
$CakeVersion = "0.25.0"
22
$DotNetChannel = "LTS";
3-
$DotNetVersion = "2.1.3";
4-
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.3/scripts/obtain/dotnet-install.ps1";
5-
$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true'
3+
$DotNetVersion = "2.1.4";
4+
$IsRunningOnUnix = [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Unix
65

76
# Make sure tools folder exists
87
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
@@ -34,23 +33,44 @@ Function Remove-PathVariable([string]$VariableToRemove)
3433
}
3534

3635
# Get .NET Core CLI path if installed.
37-
$FoundDotNetCliVersion = $null;
36+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
37+
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
38+
$FoundDotNetCliVersion = $null
39+
40+
3841
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
39-
$FoundDotNetCliVersion = dotnet --version;
42+
$FoundDotNetCliVersion = dotnet --version
4043
}
4144

42-
if($FoundDotNetCliVersion -ne $DotNetVersion) {
45+
if($FoundDotNetCliVersion -ne $DotNetVersion)
46+
{
4347
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
48+
Remove-PathVariable "$InstallPath"
49+
$env:PATH = "$InstallPath;$env:PATH"
50+
4451
if (!(Test-Path $InstallPath)) {
45-
mkdir -Force $InstallPath | Out-Null;
52+
New-Item -ItemType Directory -Force $InstallPath | Out-Null;
4653
}
47-
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
48-
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
4954

50-
Remove-PathVariable "$InstallPath"
51-
$env:PATH = "$InstallPath;$env:PATH"
52-
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
53-
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
55+
[string] $InstalledDotNetVersion = Get-ChildItem -Path ./.dotnet -File `
56+
| Where-Object { $_.Name -eq 'dotnet' -or $_.Name -eq 'dotnet.exe' } `
57+
| ForEach-Object { &$_.FullName --version }
58+
59+
if ($InstalledDotNetVersion -eq $DotNetVersion)
60+
{
61+
}
62+
elseif ($IsRunningOnUnix)
63+
{
64+
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.4/scripts/obtain/dotnet-install.sh";
65+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath/dotnet-install.sh");
66+
sudo bash "$InstallPath/dotnet-install.sh" --version $DotNetVersion --install-dir "$InstallPath" --no-path
67+
}
68+
else
69+
{
70+
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.4/scripts/obtain/dotnet-install.ps1";
71+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
72+
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
73+
}
5474
}
5575

5676
###########################################################################
@@ -67,17 +87,34 @@ Function Unzip
6787

6888

6989
# Make sure Cake has been installed.
70-
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
71-
if (!(Test-Path $CakePath)) {
90+
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion"
91+
$CakeExePath = Join-Path $CakePath "Cake.exe"
92+
$CakeZipPath = Join-Path $ToolPath "Cake.zip"
93+
if (!(Test-Path $CakeExePath)) {
7294
Write-Host "Installing Cake $CakeVersion..."
73-
(New-Object System.Net.WebClient).DownloadFile("https://www.nuget.org/api/v2/package/Cake/$CakeVersion", "$ToolPath\Cake.zip")
74-
Unzip "$ToolPath\Cake.zip" "$ToolPath/Cake.$CakeVersion"
75-
Remove-Item "$ToolPath\Cake.zip"
95+
(New-Object System.Net.WebClient).DownloadFile("https://www.nuget.org/api/v2/package/Cake/$CakeVersion", $CakeZipPath)
96+
Unzip $CakeZipPath $CakePath
97+
Remove-Item $CakeZipPath
7698
}
7799

78100
###########################################################################
79101
# RUN BUILD SCRIPT
80102
###########################################################################
81-
82-
& "$CakePath" $args
83-
exit $LASTEXITCODE
103+
if ($IsRunningOnUnix)
104+
{
105+
& mono "$CakeExePath" --bootstrap
106+
if ($LASTEXITCODE -eq 0)
107+
{
108+
& mono "$CakeExePath" $args
109+
}
110+
exit $LASTEXITCODE
111+
}
112+
else
113+
{
114+
& "$CakeExePath" --bootstrap
115+
if ($LASTEXITCODE -eq 0)
116+
{
117+
& "$CakeExePath" $args
118+
}
119+
exit $LASTEXITCODE
120+
}

build.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
#!/usr/bin/env bash
2-
##########################################################################
3-
# This is the Cake bootstrapper script for Linux and OS X.
4-
# This file was downloaded from https://github.com/cake-build/resources
5-
# Feel free to change this file to fit your needs.
6-
##########################################################################
7-
8-
# Define directories.
2+
# Define varibles
3+
CAKE_VERSION=0.25.0
4+
DOTNET_SDK_VERSION=2.1.4
95
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
106
TOOLS_DIR=$SCRIPT_DIR/tools
11-
CAKE_VERSION=0.24.0
127
CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe
13-
export CAKE_NUGET_USEINPROCESSCLIENT="true"
148

159
# Make sure the tools folder exist.
1610
if [ ! -d "$TOOLS_DIR" ]; then
@@ -25,8 +19,8 @@ echo "Installing .NET CLI..."
2519
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
2620
mkdir "$SCRIPT_DIR/.dotnet"
2721
fi
28-
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://raw.githubusercontent.com/dotnet/cli/v2.1.3/scripts/obtain/dotnet-install.sh
29-
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.3 --install-dir .dotnet --no-path
22+
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://raw.githubusercontent.com/dotnet/cli/v$DOTNET_SDK_VERSION/scripts/obtain/dotnet-install.sh
23+
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_SDK_VERSION --install-dir .dotnet --no-path
3024
export PATH="$SCRIPT_DIR/.dotnet":$PATH
3125
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
3226
export DOTNET_CLI_TELEMETRY_OPTOUT=1
@@ -57,4 +51,4 @@ fi
5751
###########################################################################
5852

5953
# Start Cake
60-
exec mono "$CAKE_EXE" "$@"
54+
(exec mono "$CAKE_EXE" --bootstrap) && (exec mono "$CAKE_EXE" "$@")

0 commit comments

Comments
 (0)