forked from App-vNext/Polly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
executable file
·86 lines (70 loc) · 2.07 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /usr/bin/env pwsh
<#
.SYNOPSIS
This is a PowerShell script to bootstrap a Cake build.
.DESCRIPTION
This PowerShell script will restore NuGet tools (including Cake)
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 WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.LINK
https://cakebuild.net
#>
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[ValidateSet("Default", "MutationCore", "MutationLegacy")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$SkipToolPackageRestore,
[switch]$Verbose
)
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
Write-Host "Preparing to run build script..."
# Should we show verbose messages?
if ($Verbose.IsPresent)
{
$VerbosePreference = "continue"
}
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
# Is this a dry run?
$UseDryRun = "";
if ($WhatIf.IsPresent) {
$UseDryRun = "-dryrun"
}
# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
New-Item -Path $TOOLS_DIR -Type directory | out-null
}
# Restore tools from NuGet?
if (-Not $SkipToolPackageRestore.IsPresent)
{
# Restore tools from NuGet.
Push-Location
Set-Location $TOOLS_DIR
Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "& dotnet tool restore"
Write-Verbose ($NuGetOutput | Out-String)
Pop-Location
if ($LASTEXITCODE -ne 0)
{
exit $LASTEXITCODE
}
}
# Start Cake
Write-Host "Running build script..."
Invoke-Expression "dotnet dotnet-cake `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseDryRun"
exit $LASTEXITCODE