forked from k1tbyte/Wand-Enhancer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
122 lines (96 loc) · 3.4 KB
/
Copy pathbuild.ps1
File metadata and controls
122 lines (96 loc) · 3.4 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
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
param(
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[switch]$EnableUpdateNotifications
)
$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$webPanelDir = Join-Path $repoRoot 'web-panel'
$solutionPath = Join-Path $repoRoot 'Wand-Enhancer.sln'
function Resolve-CommandPath {
param([string]$Name)
$command = Get-Command $Name -ErrorAction SilentlyContinue
if (-not $command) {
throw "Required command not found in PATH: $Name"
}
return $command.Source
}
function Resolve-VisualStudioPath {
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio\Installer\vswhere.exe'
if (-not (Test-Path $vswhere)) {
throw "vswhere.exe not found: $vswhere"
}
$installationPath = & $vswhere -latest -prerelease -products '*' -requires Microsoft.Component.MSBuild -property installationPath
if ([string]::IsNullOrWhiteSpace($installationPath)) {
throw 'Visual Studio with MSBuild was not found.'
}
return $installationPath
}
function Resolve-MSBuildPath {
param([string]$VisualStudioPath)
$msbuildPath = Join-Path $VisualStudioPath 'MSBuild\Current\Bin\MSBuild.exe'
if (-not (Test-Path $msbuildPath)) {
throw "MSBuild.exe not found: $msbuildPath"
}
return $msbuildPath
}
function Invoke-Step {
param(
[string]$Label,
[scriptblock]$Action
)
Write-Host "==> $Label" -ForegroundColor Cyan
& $Action
if ($LASTEXITCODE -ne 0) {
throw "Step failed: $Label"
}
}
function Resolve-TargetFrameworkRoot {
# Some local targeting packs are installed but not registered with MSBuild.
$root = Join-Path ${env:ProgramFiles(x86)} 'Reference Assemblies\Microsoft\Framework'
$frameworkList = Join-Path $root '.NETFramework\v4.8\RedistList\FrameworkList.xml'
if (Test-Path $frameworkList) {
return $root
}
return $null
}
$pnpm = Resolve-CommandPath 'pnpm'
$visualStudio = Resolve-VisualStudioPath
$msbuild = Resolve-MSBuildPath $visualStudio
$targetFrameworkRoot = Resolve-TargetFrameworkRoot
$buildArgs = @('/m', "/p:Configuration=$Configuration", '/p:Platform=Any CPU')
if ($targetFrameworkRoot) {
$buildArgs += "/p:TargetFrameworkRootPath=$targetFrameworkRoot"
}
if ($EnableUpdateNotifications) {
$buildArgs += '/p:EnableUpdateNotifications=true'
}
Invoke-Step 'Install web-panel dependencies' {
& $pnpm --dir $webPanelDir install --frozen-lockfile
}
Invoke-Step 'Lint web-panel' {
& $pnpm --dir $webPanelDir run lint
}
Invoke-Step 'Build web-panel' {
& $pnpm --dir $webPanelDir run build
}
Invoke-Step 'Test web-panel' {
& $pnpm --dir $webPanelDir exec vitest run
}
Invoke-Step 'Restore NuGet packages' {
& $msbuild $solutionPath /m /t:Restore /p:RestorePackagesConfig=true
}
Invoke-Step 'Build solution' {
& $msbuild $solutionPath @buildArgs /t:Build
}
$assemblyPath = Join-Path $repoRoot "WandEnhancer\bin\$Configuration\WandEnhancer.exe"
Invoke-Step 'Test desktop patch state and interop' {
& (Join-Path $repoRoot 'scripts\test-desktop.ps1') `
-AssemblyPath $assemblyPath `
-ExpectUpdateNotifications:$EnableUpdateNotifications
}
Invoke-Step 'Test structural patch locators' {
& (Join-Path $repoRoot 'scripts\test-patch-locators.ps1') -AssemblyPath $assemblyPath
}
Write-Host ''
Write-Host "Build completed successfully ($Configuration)." -ForegroundColor Green