Skip to content

Commit

Permalink
Updated to Cake 0.25.0
Browse files Browse the repository at this point in the history
* PowerShell core bootstrapper support
  • Loading branch information
devlead committed Jan 24, 2018
1 parent 1e6b63e commit c8f363c
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 34 deletions.
81 changes: 59 additions & 22 deletions build.ps1
@@ -1,8 +1,7 @@
$CakeVersion = "0.24.0"
$CakeVersion = "0.25.0"
$DotNetChannel = "LTS";
$DotNetVersion = "2.1.3";
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.3/scripts/obtain/dotnet-install.ps1";
$ENV:CAKE_NUGET_USEINPROCESSCLIENT='true'
$DotNetVersion = "2.1.4";
$IsRunningOnUnix = [System.Environment]::OSVersion.Platform -eq [System.PlatformID]::Unix

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

# Get .NET Core CLI path if installed.
$FoundDotNetCliVersion = $null;
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
$FoundDotNetCliVersion = $null


if (Get-Command dotnet -ErrorAction SilentlyContinue) {
$FoundDotNetCliVersion = dotnet --version;
$FoundDotNetCliVersion = dotnet --version
}

if($FoundDotNetCliVersion -ne $DotNetVersion) {
if($FoundDotNetCliVersion -ne $DotNetVersion)
{
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"

if (!(Test-Path $InstallPath)) {
mkdir -Force $InstallPath | Out-Null;
New-Item -ItemType Directory -Force $InstallPath | Out-Null;
}
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
[string] $InstalledDotNetVersion = Get-ChildItem -Path ./.dotnet -File `
| Where-Object { $_.Name -eq 'dotnet' -or $_.Name -eq 'dotnet.exe' } `
| ForEach-Object { &$_.FullName --version }

if ($InstalledDotNetVersion -eq $DotNetVersion)
{
}
elseif ($IsRunningOnUnix)
{
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.4/scripts/obtain/dotnet-install.sh";
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath/dotnet-install.sh");
sudo bash "$InstallPath/dotnet-install.sh" --version $DotNetVersion --install-dir "$InstallPath" --no-path
}
else
{
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v2.1.4/scripts/obtain/dotnet-install.ps1";
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
}
}

###########################################################################
Expand All @@ -67,17 +87,34 @@ Function Unzip


# Make sure Cake has been installed.
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion/Cake.exe"
if (!(Test-Path $CakePath)) {
$CakePath = Join-Path $ToolPath "Cake.$CakeVersion"
$CakeExePath = Join-Path $CakePath "Cake.exe"
$CakeZipPath = Join-Path $ToolPath "Cake.zip"
if (!(Test-Path $CakeExePath)) {
Write-Host "Installing Cake $CakeVersion..."
(New-Object System.Net.WebClient).DownloadFile("https://www.nuget.org/api/v2/package/Cake/$CakeVersion", "$ToolPath\Cake.zip")
Unzip "$ToolPath\Cake.zip" "$ToolPath/Cake.$CakeVersion"
Remove-Item "$ToolPath\Cake.zip"
(New-Object System.Net.WebClient).DownloadFile("https://www.nuget.org/api/v2/package/Cake/$CakeVersion", $CakeZipPath)
Unzip $CakeZipPath $CakePath
Remove-Item $CakeZipPath
}

###########################################################################
# RUN BUILD SCRIPT
###########################################################################

& "$CakePath" $args
exit $LASTEXITCODE
if ($IsRunningOnUnix)
{
& mono "$CakeExePath" --bootstrap
if ($LASTEXITCODE -eq 0)
{
& mono "$CakeExePath" $args
}
exit $LASTEXITCODE
}
else
{
& "$CakeExePath" --bootstrap
if ($LASTEXITCODE -eq 0)
{
& "$CakeExePath" $args
}
exit $LASTEXITCODE
}
18 changes: 6 additions & 12 deletions build.sh
@@ -1,16 +1,10 @@
#!/usr/bin/env bash
##########################################################################
# This is the Cake bootstrapper script for Linux and OS X.
# This file was downloaded from https://github.com/cake-build/resources
# Feel free to change this file to fit your needs.
##########################################################################

# Define directories.
# Define varibles
CAKE_VERSION=0.25.0
DOTNET_SDK_VERSION=2.1.4
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
CAKE_VERSION=0.24.0
CAKE_EXE=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe
export CAKE_NUGET_USEINPROCESSCLIENT="true"

# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
Expand All @@ -25,8 +19,8 @@ echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://raw.githubusercontent.com/dotnet/cli/v2.1.3/scripts/obtain/dotnet-install.sh
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version 2.1.3 --install-dir .dotnet --no-path
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://raw.githubusercontent.com/dotnet/cli/v$DOTNET_SDK_VERSION/scripts/obtain/dotnet-install.sh
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_SDK_VERSION --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
Expand Down Expand Up @@ -57,4 +51,4 @@ fi
###########################################################################

# Start Cake
exec mono "$CAKE_EXE" "$@"
(exec mono "$CAKE_EXE" --bootstrap) && (exec mono "$CAKE_EXE" "$@")

0 comments on commit c8f363c

Please sign in to comment.