-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
74 lines (62 loc) · 2.59 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
#################################################################################################################
# This is the MicroElements.DevOps Cake bootstrapper script for PowerShell.
# For latest version see: https://github.com/micro-elements/MicroElements.DevOps/blob/master/resources/build.ps1
#################################################################################################################
[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target,
[string]$Configuration,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
Write-Host "Preparing to run build script..."
if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
$CAKE_VERSION = "0.29.0"
$CAKE_BAKERY_VERSION = "0.3.0"
$DEVOPS_VERSION = "1.9.0"
$NUGET_URL = "https://api.nuget.org/v3/index.json"
$NUGET_BETA_URL = "https://www.myget.org/F/micro-elements/api/v3/index.json"
#$NUGET_URL = "file://C:\NuGet"
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$CAKE_DLL = Join-Path $TOOLS_DIR "Cake.CoreCLR/$CAKE_VERSION/Cake.dll"
# Script to run.
$Script = Join-Path $TOOLS_DIR "microelements.devops/$DEVOPS_VERSION/scripts/main.cake"
$cake_props = @"
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cake.CoreCLR" Version="$CAKE_VERSION" />
<PackageReference Include="Cake.Bakery" Version="$CAKE_BAKERY_VERSION" />
<PackageReference Include="MicroElements.DevOps" Version="$DEVOPS_VERSION" />
</ItemGroup>
</Project>
"@
$cake_props_path = ".\tools\cake.props"
if(!(Test-Path $cake_props_path))
{
New-Item -ItemType Directory -Force -Path $TOOLS_DIR
$cake_props >> $cake_props_path
}
# Restore Cake
&dotnet restore $cake_props_path --packages $TOOLS_DIR --source @("$NUGET_URL") --source @("$NUGET_BETA_URL")
# Build Cake arguments
$cakeArguments = @("$Script");
if ($Target) { $cakeArguments += "-target=$Target" }
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
$cakeArguments += ("--rootDir="+@("$PSScriptRoot"));
$cakeArguments += ("--devOpsVersion=$DEVOPS_VERSION");
$cakeArguments += ("--devOpsRoot=""$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION""");
$cakeArguments += $ScriptArgs
# Start Cake
Write-Host "Running build script..."
Write-Host "CakeArguments: $cakeArguments"
&dotnet $CAKE_DLL $cakeArguments
exit $LASTEXITCODE