Repository navigation
Expand file tree
/
Copy pathrebuild-all.ps1
More file actions
163 lines (134 loc) · 6.34 KB
/
Copy pathrebuild-all.ps1
File metadata and controls
163 lines (134 loc) · 6.34 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
param(
[switch]$Debug,
[switch]$Release
)
if (-not $Debug -and -not $Release) {
$Debug = $true
$Release = $true
}
# Every path below is relative to the repo root.
Set-Location $PSScriptRoot
$msbuild = "C:\Program Files\Microsoft Visual Studio\18\Community\MSBuild\Current\Bin\MSBuild.exe"
# Correct build order: dependencies first, then VSTO last
$projects = @(
# Shared libraries (no dependencies)
"KleiKodeshVsto/WpfLib/WpfLib/WpfLib.csproj",
# DocDesign (depends on WpfLib)
"KleiKodeshVsto/DocDesign/DocDesignTaskPane/DocDesignTaskPane.csproj",
"KleiKodeshVsto/DocDesign/DocDesignTaskPaneDebugger/DocDesignTaskPaneDebugger.csproj",
# RegexFind (depends on WpfLib)
"KleiKodeshVsto/RegexInWord/RegexFindTaskPane/RegexFindTaskPane.csproj",
"KleiKodeshVsto/RegexInWord/RegexFindTaskPaneDebugger/RegexFindTaskPaneDebugger.csproj",
# WebSites (depends on WpfLib)
"KleiKodeshVsto/WebSitesTaskPane/WebSitesTaskPane/WebSitesTaskPane.csproj",
"KleiKodeshVsto/WebSitesTaskPane/WebSitesTaskPaneDebugger/WebSitesTaskPaneDebugger.csproj",
# Kiwix (no WpfLib dependency)
"KleiKodeshVsto/Kiwix/KiwixTaskPane/KiwixTaskPane.csproj",
"KleiKodeshVsto/Kiwix/KiwixTaskPaneDebugger/KiwixTaskPaneDebugger.csproj",
# Nakdan (depends on WpfLib)
"KleiKodeshVsto/Nakdan/NakdanTaskPane/NakdanTaskPane.csproj",
"KleiKodeshVsto/Nakdan/NakdanTaskPaneDebugger/NakdanTaskPaneDebugger.csproj",
# KitveiHakodesh backend
"KitveiHakodesh/CSharpBackend/FtsLib-Csharp/FtsLib/FtsLib.csproj",
"KitveiHakodesh/CSharpBackend/FtsLib-Csharp/FtsLibTest/FtsLibTest.csproj",
"KitveiHakodesh/CSharpBackend/KitveiHakodeshLib/KitveiHakodeshLib.csproj",
"KitveiHakodesh/CSharpBackend/KitveiHakodeshDesktopApp/KitveiHakodeshDesktopApp.csproj",
# VSTO add-in LAST (depends on all libraries above)
"KleiKodeshVsto/KleiKodeshVsto.csproj"
# The setup exe is built by Build/build.ps1 (Rust).
)
$configurations = @()
if ($Debug) { $configurations += "Debug" }
if ($Release) { $configurations += "Release" }
$totalProjects = $projects.Count
$totalBuilds = $totalProjects * $configurations.Count
$successCount = 0
$failureCount = 0
$failures = @()
Write-Host "`nKleiKodesh Solution - Rebuild All Projects" -ForegroundColor Cyan
Write-Host "Total projects: $totalProjects | Configurations: $($configurations -join ', ')" -ForegroundColor Yellow
# Clean all bin and obj folders before building
Write-Host "`nCleaning bin/obj folders..." -ForegroundColor Yellow
$cleaned = 0
Get-ChildItem -Path "." -Recurse -Directory -Include "bin","obj" |
Where-Object { $_.FullName -notmatch '\\(node_modules|\.git|packages)\\' } |
Sort-Object { $_.FullName.Length } -Descending |
ForEach-Object {
if (Test-Path $_.FullName) {
Remove-Item $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
$cleaned++
}
}
Write-Host " Removed $cleaned folders" -ForegroundColor Gray
# SDK-style projects need dotnet restore: project.assets.json lives in obj, which was just
# deleted. Detected from $projects so this can't drift from the build list.
$sdkProjects = @($projects | Where-Object { Select-String -Path $_ -Pattern '<Project Sdk=' -Quiet })
Write-Host "`nRestoring SDK-style projects..." -ForegroundColor Yellow
foreach ($sdkProject in $sdkProjects) {
$projectName = Split-Path -Leaf $sdkProject
Write-Host " $projectName... " -NoNewline -ForegroundColor Gray
$restoreOutput = & dotnet restore $sdkProject 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "OK" -ForegroundColor Green
} else {
Write-Host "FAIL" -ForegroundColor Red
$restoreOutput | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
}
}
$startTime = Get-Date
foreach ($config in $configurations) {
Write-Host "`nBuilding in $config configuration..." -ForegroundColor Magenta
$configStartTime = Get-Date
$configSuccessCount = 0
for ($i = 0; $i -lt $projects.Count; $i++) {
$project = $projects[$i]
$projectNum = $i + 1
$projectName = Split-Path -Leaf $project
Write-Host " [$projectNum/$totalProjects] $projectName... " -NoNewline -ForegroundColor Gray
$output = & $msbuild $project /m /nologo /verbosity:minimal /p:Configuration=$config 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Host "OK" -ForegroundColor Green
# Show any warnings even on success
$warnings = $output | Where-Object { $_ -match ": warning " }
if ($warnings) {
$warnings | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
}
$successCount++
$configSuccessCount++
}
else {
Write-Host "FAIL" -ForegroundColor Red
$errors = $output | Where-Object { $_ -match ": error " }
$warnings = $output | Where-Object { $_ -match ": warning " }
if ($warnings) {
$warnings | ForEach-Object { Write-Host " $_" -ForegroundColor Yellow }
}
if ($errors) {
$errors | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
} else {
# Fallback: show all output if no specific errors found
$output | ForEach-Object { Write-Host " $_" -ForegroundColor Red }
}
$failureCount++
$failures += "$project ($config)"
}
}
$configEndTime = Get-Date
$configDuration = [math]::Round(($configEndTime - $configStartTime).TotalSeconds, 2)
Write-Host " $config result: $configSuccessCount/$totalProjects successful in $configDuration seconds" -ForegroundColor Cyan
}
$endTime = Get-Date
$totalDuration = [math]::Round(($endTime - $startTime).TotalSeconds, 2)
Write-Host "`nSummary:" -ForegroundColor Cyan
Write-Host " Successful: $successCount/$totalBuilds" -ForegroundColor Green
Write-Host " Failed: $failureCount/$totalBuilds" -ForegroundColor $(if ($failureCount -eq 0) { "Green" } else { "Red" })
Write-Host " Duration: $totalDuration seconds" -ForegroundColor Cyan
if ($failures.Count -gt 0) {
Write-Host "`nFailed builds:" -ForegroundColor Red
$failures | ForEach-Object { Write-Host " - $_" -ForegroundColor Red }
exit 1
}
else {
Write-Host "`nAll projects rebuilt successfully!" -ForegroundColor Green
exit 0
}