forked from Thealexbarney/VGAudio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
131 lines (115 loc) · 3.97 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<#
.SYNOPSIS
This is a Powershell script to bootstrap a Cake build.
.DESCRIPTION
This Powershell script will the .NET Core CLI if missing,
and execute your Cake build script with the parameters you provide.
.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.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
http://cakebuild.net
#>
[CmdletBinding()]
Param(
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Normal",
[switch]$WhatIf,
[switch]$NetCore,
[switch]$NetFramework,
[switch]$Uwp,
[switch]$UwpStore,
[switch]$Build,
[switch]$Test,
[switch]$Clean,
[switch]$CleanAll,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
$dotnetCliVersion = Get-Content DotnetCLIVersion.txt
# Define directories.
$basePath = Split-Path $MyInvocation.MyCommand.Path -Parent
$buildPath = Join-Path $basePath "build"
$dotnetPath = Join-Path $basePath "tools/dotnet"
$dotnetCliPath = Join-Path $dotnetPath "cli"
$globalJsonFile = Join-Path $basePath global.json
###########################################################################
# INSTALL .NET CORE CLI
###########################################################################
function SetupDotnetCli() {
$json = "{`"projects`":[],`"sdk`":{`"version`":`"$dotnetCliVersion`"}}"
Out-File -FilePath $globalJsonFile -Encoding utf8 -InputObject $json
if ((Get-Command "dotnet" -errorAction SilentlyContinue) -and (& dotnet --version) -eq $dotnetCliVersion) {
return
}
$appDataInstallPath = Join-Path $env:LocalAppData "Microsoft/dotnet"
$path = Join-Path $appDataInstallPath dotnet.exe
if ((Test-Path $path) -and (& $path --version) -eq $dotnetCliVersion) {
$env:Path = "$appDataInstallPath;" + $env:path
return
}
$path = Join-Path $dotnetCliPath dotnet.exe
if ((Test-Path $path) -and (& $path --version) -eq $dotnetCliVersion) {
$env:Path = "$dotnetCliPath;" + $env:path
return
}
Write-Output "Downloading .NET Core CLI..."
try {
& (Join-Path $dotnetPath dotnet-install.ps1) -InstallDir $dotnetCliPath -Version $dotnetCliVersion -NoPath
} catch {
Write-Output "Error downloading .NET Core CLI"
}
if ((Test-Path $path) -and (& $path --version) -eq $dotnetCliVersion) {
$env:Path = "$dotnetCliPath;" + $env:path
return
}
Write-Output "Unable to locate or download .NET Core CLI version $dotnetCliVersion"
exit 1
}
# Make sure .NET Core CLI exists.
try {
Push-Location $buildPath
$originalEnvPath = $env:Path
SetupDotnetCli
# HP sets the "Platform" environment variable with some of their software
# Clear that to allow the build to work
$env:Platform = ""
###########################################################################
# RUN BUILD SCRIPT
###########################################################################
# Build the argument list.
$Arguments = @{
target=$Target;
configuration=$Configuration;
verbosity=$Verbosity;
dryrun=$WhatIf;
core=$NetCore;
full=$NetFramework;
uwp=$Uwp;
uwpstore=$UwpStore;
build=$Build;
test=$Test;
clean=$Clean;
cleanall=$CleanAll;
}.GetEnumerator() | ForEach-Object {"--{0}=`"{1}`"" -f $_.key, $_.value };
# Start Cake
Write-Output "Running build..."
& dotnet publish /v:q /nologo
& dotnet bin/Debug/netcoreapp2.0/publish/Build.dll $Arguments
exit $LASTEXITCODE;
} finally {
Pop-Location;
Remove-Item $globalJsonFile
$env:Path = $originalEnvPath
}