-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuild.ps1
83 lines (66 loc) · 2.25 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
Param(
[string]$Configuration = "Release",
[string]$SDKVersion,
[bool]$IsAzurePipelineBuild = $false,
[switch]$Help = $false
)
$StartTime = Get-Date
if ($Help) {
Write-Host @"
Copyright (c) Microsoft Corporation and Contributors.
Licensed under the MIT License.
Syntax:
Build.cmd [options]
Description:
Builds Dev Home SDK.
Options:
-Configuration <configuration>
Only build the selected configuration(s)
Example: -Configuration Release
Example: -Configuration "Debug,Release"
-Help
Display this usage message.
"@
Exit
}
$ErrorActionPreference = "Stop"
$buildPlatforms = "x64","x86","arm64","AnyCPU"
$env:Build_Configuration = $Configuration
$msbuildPath = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
if ($IsAzurePipelineBuild) {
$nugetPath = "nuget.exe";
} else {
$nugetPath = (Join-Path $PSScriptRoot "..\build\NugetWrapper.cmd")
}
New-Item -ItemType Directory -Force -Path "$PSScriptRoot\_build"
& $nugetPath restore (Join-Path $PSScriptRoot DevHomeSDK.sln)
Try {
foreach ($platform in $buildPlatforms) {
foreach ($configuration in $env:Build_Configuration.Split(",")) {
$msbuildArgs = @(
("$PSScriptRoot\DevHomeSDK.sln"),
("/p:Platform="+$platform),
("/p:Configuration="+$configuration),
("/binaryLogger:DevHome.SDK.$platform.$configuration.binlog")
)
& $msbuildPath $msbuildArgs
}
}
} Catch {
$formatString = "`n{0}`n`n{1}`n`n"
$fields = $_, $_.ScriptStackTrace
Write-Host ($formatString -f $fields) -ForegroundColor RED
Exit 1
}
& $nugetPath pack (Join-Path $PSScriptRoot "nuget\Microsoft.Windows.DevHome.SDK.nuspec") -Version $SDKVersion -OutputDirectory "$PSScriptRoot\_build"
if ($IsAzurePipelineBuild) {
Write-Host "##vso[task.setvariable variable=SDKVersion;]$SDKVersion"
Write-Host "##vso[task.setvariable variable=SDKVersion;isOutput=true;]$SDKVersion"
}
$TotalTime = (Get-Date)-$StartTime
$TotalMinutes = [math]::Floor($TotalTime.TotalMinutes)
$TotalSeconds = [math]::Ceiling($TotalTime.TotalSeconds)
Write-Host @"
Total Running Time:
$TotalMinutes minutes and $TotalSeconds seconds
"@ -ForegroundColor CYAN