forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
125 lines (100 loc) · 5.37 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
#
# 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",
[string]$Platform="Any CPU",
[string]$Verbosity="minimal",
[switch]$SkipTests,
[switch]$FullMSBuild,
[switch]$RealSign,
[switch]$Help)
if($Help)
{
Write-Host "Usage: .\build.ps1 [Options]"
Write-Host ""
Write-Host "Options:"
Write-Host " -Configuration <CONFIGURATION> Build the specified Configuration (Debug or Release, default: Debug)"
Write-Host " -Platform <PLATFORM> Build the specified Platform (Any CPU)"
Write-Host " -Verbosity <VERBOSITY> Build console output verbosity (minimal or diagnostic, default: minimal)"
Write-Host " -SkipTests Skip executing unit tests"
Write-Host " -FullMSBuild Run tests with the full .NET Framework version of MSBuild instead of the .NET Core version"
Write-Host " -RealSign Sign the output DLLs"
Write-Host " -Help Display this help message"
exit 0
}
$RepoRoot = "$PSScriptRoot"
$PackagesPath = "$RepoRoot\packages"
$env:NUGET_PACKAGES = $PackagesPath
$DotnetCLIVersion = Get-Content "$RepoRoot\DotnetCLIVersion.txt"
# Use a repo-local install directory (but not the bin directory because that gets cleaned a lot)
if (!$env:DOTNET_INSTALL_DIR)
{
$env:DOTNET_INSTALL_DIR="$RepoRoot\.dotnet_cli\"
}
if (!(Test-Path $env:DOTNET_INSTALL_DIR))
{
mkdir $env:DOTNET_INSTALL_DIR | Out-Null
}
if ($Verbosity -eq 'diagnostic') {
$dotnetInstallVerbosity = "-Verbose"
}
# Install a stage 0
$DOTNET_INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1"
Invoke-WebRequest $DOTNET_INSTALL_SCRIPT_URL -OutFile "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1"
& "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1" -Version $DotnetCLIVersion $dotnetInstallVerbosity
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
# Install 1.0.4 shared framework
if (!(Test-Path "$env:DOTNET_INSTALL_DIR\shared\Microsoft.NETCore.App\1.0.4"))
{
& "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1" -Channel "Preview" -Version 1.0.4 -SharedRuntime
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
}
# Install 1.1.1 shared framework
if (!(Test-Path "$env:DOTNET_INSTALL_DIR\shared\Microsoft.NETCore.App\1.1.1"))
{
& "$env:DOTNET_INSTALL_DIR\dotnet-install.ps1" -Channel "Release/1.1.0" -Version 1.1.1 -SharedRuntime
if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" }
}
# Put the stage0 on the path
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
# Disable first run since we want to control all package sources
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
$logPath = "$RepoRoot\bin\log"
if (!(Test-Path -Path $logPath)) {
New-Item -Path $logPath -Force -ItemType 'Directory' | Out-Null
}
$signType = 'public'
if ($RealSign) {
$signType = 'real'
}
$buildTarget = 'Build'
if ($SkipTests) {
$buildTarget = 'BuildWithoutTesting'
}
if ($FullMSBuild)
{
$env:DOTNET_SDK_TEST_MSBUILD_PATH = join-path $env:VSInstallDir "MSBuild\15.0\bin\MSBuild.exe"
}
$commonBuildArgs = echo $RepoRoot\build\build.proj /m:1 /nologo /p:Configuration=$Configuration /p:Platform=$Platform /p:SignType=$signType /verbosity:$Verbosity
# NET Core Build
$msbuildSummaryLog = Join-Path -path $logPath -childPath "sdk.log"
$msbuildWarningLog = Join-Path -path $logPath -childPath "sdk.wrn"
$msbuildFailureLog = Join-Path -path $logPath -childPath "sdk.err"
dotnet msbuild /t:$buildTarget $commonBuildArgs /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildFailureLog
if($LASTEXITCODE -ne 0) { throw "Failed to build" }
# Template Build
$msbuildSummaryLog = Join-Path -path $logPath -childPath "templates.log"
$msbuildWarningLog = Join-Path -path $logPath -childPath "templates.wrn"
$msbuildFailureLog = Join-Path -path $logPath -childPath "templates.err"
msbuild /t:restore /p:RestorePackagesPath=$PackagesPath $RepoRoot\sdk-templates.sln /verbosity:$Verbosity
if($LASTEXITCODE -ne 0) { throw "Failed to restore nuget packages for templates" }
msbuild /t:$buildTarget $commonBuildArgs /nr:false /p:BuildTemplates=true /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildFailureLog
if($LASTEXITCODE -ne 0) { throw "Failed to build templates" }
# Modern VSIX build
$msbuildSummaryLog = Join-Path -path $logPath -childPath "modernvsix.log"
$msbuildWarningLog = Join-Path -path $logPath -childPath "modernvsix.wrn"
$msbuildFailureLog = Join-Path -path $logPath -childPath "modernvsix.err"
msbuild /t:BuildModernVsixPackages $commonBuildArgs /nr:false /p:BuildTemplates=true /flp1:Summary`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildSummaryLog /flp2:WarningsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildWarningLog /flp3:ErrorsOnly`;Verbosity=diagnostic`;Encoding=UTF-8`;LogFile=$msbuildFailureLog
if($LASTEXITCODE -ne 0) { throw "Failed to build modern vsix packages" }