This repository has been archived by the owner on Dec 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.ps1
55 lines (41 loc) · 1.99 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
[CmdletBinding()]
Param(
[switch]$NoInit,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { $host.SetShouldExit(1) }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
###########################################################################
# CONFIGURATION
###########################################################################
$DotNetChannel = "2.0"
$BuildProjectFile = "$PSScriptRoot\.\build\.build.csproj"
$TempDirectory = "$PSScriptRoot\.\.tmp"
$DotNetScriptUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
$DotNetDirectory = "$TempDirectory\dotnet-win"
$DotNetFile = "$DotNetDirectory\dotnet.exe"
$env:DOTNET_EXE = $DotNetFile
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:NUGET_XMLDOC_MODE = "skip"
###########################################################################
# PREPARE BUILD
###########################################################################
function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LastExitCode -ne 0) { throw "The following call failed with exit code $LastExitCode. '$cmd'" }
}
if (!$NoInit) {
md -force $DotNetDirectory > $null
$DotNetScriptFile = "$TempDirectory\dotnet-install.ps1"
if (!(Test-Path $DotNetScriptFile)) { (New-Object System.Net.WebClient).DownloadFile($DotNetScriptUrl, $DotNetScriptFile) }
ExecSafe { & $DotNetScriptFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
ExecSafe { & $DotNetFile restore $BuildProjectFile }
}
ExecSafe { & $DotNetFile build $BuildProjectFile --no-restore }
###########################################################################
# EXECUTE BUILD
###########################################################################
& $DotNetFile run --project $BuildProjectFile --no-build -- $BuildArguments
exit $LASTEXITCODE