forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-bootstrap.ps1
80 lines (66 loc) · 2.57 KB
/
make-bootstrap.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
# Make a bootstrap compiler and install it into artifacts/bootstrap folder
[CmdletBinding(PositionalBinding=$false)]
param (
[string]$name = "local",
[string]$toolset = "Default",
[string]$configuration = "Release",
[switch]$force = $false,
[switch]$ci = $false
)
Set-StrictMode -version 2.0
$ErrorActionPreference="Stop"
try {
. (Join-Path $PSScriptRoot "build-utils.ps1")
$bootstrapDir = Join-Path $ArtifactsDir "bootstrap" $name
Write-Host "Building bootstrap compiler into $bootstrapDir"
if (Test-Path $bootstrapDir) {
if ($force) {
Write-Host "Removing existing bootstrap compiler"
Remove-Item -Recurse -Force $bootstrapDir
}
else {
Write-Host "Bootstrap compiler already exists. Use -force to rebuild"
exit 1
}
}
if ($toolset -ieq "Default") {
$projectPath = "src\NuGet\Microsoft.Net.Compilers.Toolset\AnyCpu\Microsoft.Net.Compilers.Toolset.Package.csproj"
$packageName = "Microsoft.Net.Compilers.Toolset"
}
elseif ($toolset -ieq "Framework") {
$projectPath = "src\NuGet\Microsoft.Net.Compilers.Toolset\Framework\Microsoft.Net.Compilers.Toolset.Framework.Package.csproj"
$packageName = "Microsoft.Net.Compilers.Toolset.Framework"
}
else {
throw "Unsupported bootstrap toolset $toolset"
}
$binaryLogFilePath = Join-Path $LogDir "bootstrap-$($name).binlog"
# Because we override the C#/VB toolset to build against our LKG package, it is important
# that we do not reuse MSBuild nodes from other jobs/builds on the machine. Otherwise,
# we'll run into issues such as https://github.com/dotnet/roslyn/issues/6211.
# MSBuildAdditionalCommandLineArgs=
$args = "/p:TreatWarningsAsErrors=true /warnaserror /nologo /nodeReuse:false /p:Configuration=$configuration /v:m";
$args += " /p:RunAnalyzersDuringBuild=false /bl:$binaryLogFilePath"
$args += " /t:Pack /p:RoslynEnforceCodeStyle=false /p:DotNetUseShippingVersions=true /p:InitialDefineConstants=BOOTSTRAP"
$args += " /p:PackageOutputPath=$bootstrapDir /p:NgenOptimization=false /p:PublishWindowsPdb=false"
if ($ci) {
$args += " /p:ContinuousIntegrationBuild=true"
}
Exec-DotNet "build $args $projectPath"
$packageFilePath = Get-ChildItem -Path $bootstrapDir -Filter "$packageName.*.nupkg"
Write-Host "Found package $packageFilePath"
Unzip $packageFilePath.FullName $bootstrapDir
Write-Host "Cleaning up artifacts"
Exec-DotNet "build --no-restore /t:Clean $projectPath"
Exec-DotNet "build-server shutdown"
exit 0
}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}
finally {
Pop-Location
}