2018-07-23 19:28:56 +00:00
|
|
|
##########################################################################
|
2018-10-04 16:57:14 +00:00
|
|
|
# This is a customized Cake bootstrapper script for PowerShell.
|
2018-07-23 19:28:56 +00:00
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
<#
|
|
|
|
|
|
|
|
.SYNOPSIS
|
|
|
|
This is a Powershell script to bootstrap a Cake build.
|
|
|
|
|
|
|
|
.DESCRIPTION
|
2018-10-04 16:57:14 +00:00
|
|
|
This Powershell script restores NuGet tools (including Cake)
|
2018-07-23 19:28:56 +00:00
|
|
|
and execute your Cake build script with the parameters you provide.
|
|
|
|
|
|
|
|
.PARAMETER Script
|
|
|
|
The build script to execute.
|
|
|
|
.PARAMETER Target
|
|
|
|
The build script target to run.
|
|
|
|
.PARAMETER Configuration
|
|
|
|
The build configuration to use.
|
|
|
|
.PARAMETER Verbosity
|
|
|
|
Specifies the amount of information to be displayed.
|
|
|
|
.PARAMETER ShowDescription
|
|
|
|
Shows description about tasks.
|
|
|
|
.PARAMETER DryRun
|
|
|
|
Performs a dry run.
|
|
|
|
.PARAMETER ScriptArgs
|
|
|
|
Remaining arguments are added here.
|
|
|
|
|
|
|
|
.LINK
|
|
|
|
https://cakebuild.net
|
|
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
[CmdletBinding()]
|
|
|
|
Param(
|
|
|
|
[string]$Script = "build.cake",
|
|
|
|
[string]$Target,
|
|
|
|
[string]$Configuration,
|
|
|
|
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
|
|
|
[string]$Verbosity,
|
|
|
|
[switch]$ShowDescription,
|
|
|
|
[Alias("WhatIf", "Noop")]
|
|
|
|
[switch]$DryRun,
|
2019-02-15 22:47:22 +00:00
|
|
|
[Parameter(Position = 0, Mandatory = $false, ValueFromRemainingArguments = $true)]
|
2018-07-23 19:28:56 +00:00
|
|
|
[string[]]$ScriptArgs
|
|
|
|
)
|
|
|
|
|
|
|
|
Write-Host "Preparing to run build script..."
|
|
|
|
|
2018-10-04 16:57:14 +00:00
|
|
|
# Determine the script root for resolving other paths.
|
2019-02-15 22:47:22 +00:00
|
|
|
if(!$PSScriptRoot) {
|
2018-07-23 19:28:56 +00:00
|
|
|
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
|
|
|
}
|
|
|
|
|
2018-10-04 16:57:14 +00:00
|
|
|
# Resolve the paths for resources used for debugging.
|
2019-02-15 22:47:22 +00:00
|
|
|
$BUILD_DIR = Join-Path $PSScriptRoot "build"
|
|
|
|
$TOOLS_DIR = Join-Path $BUILD_DIR "tools"
|
|
|
|
$CAKE_CSPROJ = Join-Path $BUILD_DIR "cakebuild.csproj"
|
2018-07-23 19:28:56 +00:00
|
|
|
|
2018-10-04 16:57:14 +00:00
|
|
|
# Install the required tools locally.
|
|
|
|
Write-Host "Restoring cake tools..."
|
|
|
|
Invoke-Expression "dotnet restore `"$CAKE_CSPROJ`" --packages `"$TOOLS_DIR`"" | Out-Null
|
2018-07-23 19:28:56 +00:00
|
|
|
|
2018-08-05 19:45:14 +00:00
|
|
|
# Find the Cake executable
|
2019-02-15 22:47:22 +00:00
|
|
|
$CAKE_EXECUTABLE = (Get-ChildItem -Path "$TOOLS_DIR/cake.coreclr/" -Filter Cake.dll -Recurse).FullName
|
2018-07-23 19:28:56 +00:00
|
|
|
|
|
|
|
# Build Cake arguments
|
|
|
|
$cakeArguments = @("$Script");
|
|
|
|
if ($Target) { $cakeArguments += "-target=$Target" }
|
|
|
|
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
|
|
|
|
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
|
|
|
|
if ($ShowDescription) { $cakeArguments += "-showdescription" }
|
|
|
|
if ($DryRun) { $cakeArguments += "-dryrun" }
|
|
|
|
if ($Experimental) { $cakeArguments += "-experimental" }
|
|
|
|
$cakeArguments += $ScriptArgs
|
|
|
|
|
|
|
|
# Start Cake
|
|
|
|
Write-Host "Running build script..."
|
2019-02-15 22:47:22 +00:00
|
|
|
Push-Location -Path $BUILD_DIR
|
2018-08-05 19:45:14 +00:00
|
|
|
Invoke-Expression "dotnet `"$CAKE_EXECUTABLE`" $cakeArguments"
|
2019-02-15 22:47:22 +00:00
|
|
|
Pop-Location
|
2018-07-23 19:28:56 +00:00
|
|
|
exit $LASTEXITCODE
|