-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathrunbuild.ps1
85 lines (69 loc) · 2.88 KB
/
runbuild.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
# Script to run a build of Win2d - this mimics build.cmd but adds more customization options
# One of the goals is to closely mimic what the ADO pipeline does for more consistency.
# Examples:
# Build Win2D (just Microsoft.Graphics.Canvas.dll) for all versions / revisions
# .\runbuild.ps1
#
# Quickly build Win2D for inner loop
# .\runbuild.ps1 -BuildConfigurations "Debug" -BuildPlatforms "x64"
#
# Clean (delete bin/obj files)
# .\runbuild.ps1 -Clean
#
# Build and run tests
# .\runbuild.ps1 -BuildConfigurations "Debug" -BuildPlatforms "Win32;x86" -RunTests
[CmdletBinding()]
param (
[string]$BuildConfigurations,
[string]$BuildPlatforms,
[switch]$BuildTests = $false,
[switch]$BuildDocs = $false,
[switch]$RunTests = $false,
[switch]$Clean
)
$ErrorActionPreference = 'Stop';
if ($Clean) {
$objDir = Join-Path $PSScriptRoot "obj"
$binDir = Join-Path $PSScriptRoot "bin"
if (Test-Path $objDir) { Remove-Item $objDir -Recurse }
if (Test-Path $binDir) { Remove-Item $binDir -Recurse }
Write-Host "Successfully cleaned binaries!" -ForegroundColor Green
return;
}
# TODO: figure out dynamically what version of visual studio is installed
$env:VS160COMNTOOLS = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\"
$msbuildExe = "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
$projFile = Join-Path $PSScriptRoot "Win2D.proj"
$slnPath = Join-Path $PSScriptRoot "Microsoft.Graphics.Win2D.sln"
$nugetExe = Join-Path $PSScriptRoot "build\nuget\nuget.exe"
if (!(Test-Path $msbuildExe)) {
Write-Error "Could not find msbuild.exe. Is Visual Studio 2019 installed?`n Checked for msbuild.exe here: $msbuildExe"
return;
}
if (!(Test-Path $nugetExe)) {
Write-Error "Could not find nuget.exe ($nugetExe)`n Please run 'build\nuget\download-nuget.cmd' to install nuget."
return;
}
# Step 1 is nuget restore for AnyCPU projects, which MSBuild doesn't do for us
Write-Host "Beginning nuget restore..." -ForegroundColor Green
$env:Platform = "AnyCPU"
$env:Configuration = "Release"
Write-Verbose "Restoring Release, AnyCPU"
& $nugetExe restore $slnPath
$env:Configuration = "Debug"
Write-Verbose "Restoring Debug, AnyCPU"
& $nugetExe restore $slnPath
Write-Host "Beginning build..." -ForegroundColor Green
$buildConfigArg = ""
if ($BuildConfigurations) {
$buildConfigArg = "/p:BuildConfigurations=$BuildConfigurations"
}
$buildPlatformsArg = ""
if ($BuildPlatforms) {
$buildPlatformsArg = "/p:BuildPlatforms=$BuildPlatforms"
}
if ($RunTests) {
$BuildTests = $true
}
Write-Output "$msbuildExe $projFile $buildConfigArg $buildPlatformsArg /p:BuildTests=$BuildTests /p:BuildDocs=$BuildDocs /p:RunTests=$RunTests"
& $msbuildExe $projFile $buildConfigArg $buildPlatformsArg "/p:BuildTests=$BuildTests" "/p:BuildDocs=$BuildDocs" "/p:RunTests=$RunTests"