forked from dotnet/templating
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
99 lines (79 loc) · 3 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
#
# Copyright (c) .NET Foundation and contributors. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
#
param(
[string]$Configuration="Debug",
[bool]$PerformFullFrameworkBuild=$true,
[bool]$CIBuild=$false,
[bool]$SkipTests=$false,
[bool]$TemplatesBuild=-not $CIBuild,
[bool]$EngineBuild=-not $CIBuild,
[switch]$Help,
[string]$PB_SkipTests="false")
switch ($PB_SkipTests.ToLower())
{
"true" { $PB_SkipTests = "True" }
default { $PB_SkipTests = "False" }
}
if($Help)
{
Write-Host "Usage: .\build.ps1 [-Configuration <CONFIGURATION>] [-Help]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
Write-Host " -PerformFullFrameworkBuild <$true|$false> Whether or not to build for NET45 as well as .NET Core"
Write-Host " -Help Display this help message"
exit 0
}
if (!$PerformFullFrameworkBuild)
{
Write-Host "Skipping NET45 build..."
}
else
{
Write-Host "NET45 build is enabled, if invoking from setup, set the environment variable DN3FFB to $false to prevent this..."
}
$RepoRoot = "$PSScriptRoot"
$ArtifactsDir = "$RepoRoot\artifacts"
$DevDir = "$RepoRoot\dev"
$env:CONFIGURATION = $Configuration;
rm "$DevDir" -Force -Recurse
if(Test-Path "$DevDir") { throw "Failed to remove 'dev'" }
# Use a repo-local install directory (but not the artifacts directory because that gets cleaned a lot
if (!$env:DOTNET_INSTALL_DIR)
{
$env:DOTNET_INSTALL_DIR="$RepoRoot\.dotnet\"
}
if (!(Test-Path $env:DOTNET_INSTALL_DIR))
{
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
}
if (Test-Path "$RepoRoot\artifacts")
{
rm "$RepoRoot\artifacts" -Force -Recurse
}
mkdir "$RepoRoot\artifacts" | Out-Null
$DOTNET_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
Invoke-WebRequest $DOTNET_INSTALL_SCRIPT_URL -OutFile "$RepoRoot\artifacts\dotnet-install.ps1"
& "$RepoRoot\artifacts\dotnet-install.ps1" -Verbose -Version 1.0.4
if($LASTEXITCODE -ne 0) { throw "Failed to install dotnet cli" }
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
if (-not $env:BUILD_NUMBER)
{
$env:BUILD_NUMBER = 0
}
if (-not $env:PACKAGE_VERSION)
{
$env:PACKAGE_VERSION = "1.0.0"
}
$NoTimestampPackageVersion=$env:PACKAGE_VERSION
if (-not $env:BUILD_QUALITY)
{
$env:BUILD_QUALITY = "beta1"
}
$NoTimestampPackageVersion=$env:PACKAGE_VERSION + "-" + $env:BUILD_QUALITY
$TimestampPackageVersion=$NoTimestampPackageVersion + "-" + [System.DateTime]::Now.ToString("yyyyMMdd") + "-" + $env:BUILD_NUMBER
& dotnet msbuild $RepoRoot\build.proj /p:IsFullFrameworkBuildSupported=$PerformFullFrameworkBuild /p:Configuration=$Configuration /p:CIBuild=$CIBuild /p:SkipTests=$SkipTests /p:TemplatesBuild=$TemplatesBuild /p:EngineBuild=$EngineBuild /p:PB_SkipTests=$PB_SkipTests
& $RepoRoot\SetPath.ps1 -DevDir "$DevDir"