forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
71 lines (56 loc) · 1.91 KB
/
Copy pathbuild.ps1
File metadata and controls
71 lines (56 loc) · 1.91 KB
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
[CmdletBinding()]
param(
[ValidateSet('Debug', 'Release')]
[string] $Configuration = 'Release',
[ValidateSet('x64', 'ARM64')]
[string] $Platform = 'x64',
[switch] $RunTests,
[switch] $NoRestore
)
$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
& (Join-Path $PSScriptRoot 'validate-icon.ps1')
$msbuild = Get-Command 'msbuild.exe' -ErrorAction SilentlyContinue
if (-not $msbuild) {
$msbuild = Get-Command 'msbuild' -ErrorAction SilentlyContinue
}
if (-not $msbuild) {
throw 'MSBuild was not found. Run this script from a Visual Studio Developer PowerShell window.'
}
$projects = @(
'App\MouseWithoutBorders.csproj',
'MouseWithoutBorders.UnitTests\MouseWithoutBorders.UnitTests.csproj'
)
foreach ($project in $projects) {
$projectPath = Join-Path $PSScriptRoot $project
$arguments = @(
$projectPath,
'/m',
"/p:Configuration=$Configuration",
"/p:Platform=$Platform"
)
if (-not $NoRestore) {
$arguments += '/restore'
}
Write-Host "Building $project"
& $msbuild.Source @arguments
if ($LASTEXITCODE -ne 0) {
throw "Build failed for $project (exit code $LASTEXITCODE)."
}
}
if ($RunTests) {
$dotnet = Get-Command 'dotnet.exe' -ErrorAction SilentlyContinue
if (-not $dotnet) {
$dotnet = Get-Command 'dotnet' -ErrorAction SilentlyContinue
}
if (-not $dotnet) {
throw '.NET was not found. Install the .NET 10 SDK and try again.'
}
$testProject = Join-Path $PSScriptRoot 'MouseWithoutBorders.UnitTests\MouseWithoutBorders.UnitTests.csproj'
Write-Host 'Running unit tests'
& $dotnet.Source test $testProject --no-build --no-restore -c $Configuration "-p:Platform=$Platform"
if ($LASTEXITCODE -ne 0) {
throw "Unit tests failed (exit code $LASTEXITCODE)."
}
}
Write-Host "Mouse Without Borders $Configuration $Platform build completed successfully."