Skip to content

Commit 5f18e7b

Browse files
committed
Add build.ps1 script with prerequisite detection
- build.ps1 checks for .NET 9, .NET 10, Windows SDK - Provides clear guidance on what's missing - Supports building individual projects or all - Fix README: correct dotnet run command (needs full .csproj path) - Expanded Quick Start section with multiple build options Fixes #10
1 parent 2f8bac3 commit 5f18e7b

2 files changed

Lines changed: 255 additions & 5 deletions

File tree

‎README.md‎

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,46 @@ This monorepo contains three projects:
2121
## 🚀 Quick Start
2222

2323
### Prerequisites
24-
- .NET 10.0 SDK
2524
- Windows 10/11
26-
- PowerToys (for Command Palette extension)
25+
- .NET 10.0 SDK (preview) - for WinForms tray
26+
- .NET 9.0 SDK - for WinUI tray
27+
- PowerToys (optional, for Command Palette extension)
2728

2829
### Build
29-
```bash
30+
31+
Use the build script to check prerequisites and build:
32+
33+
```powershell
34+
# Check prerequisites
35+
.\build.ps1 -CheckOnly
36+
37+
# Build all projects
38+
.\build.ps1
39+
40+
# Build specific project
41+
.\build.ps1 -Project WinUI
42+
.\build.ps1 -Project Tray -Configuration Release
43+
```
44+
45+
Or build directly with dotnet:
46+
47+
```powershell
48+
# Build all
3049
dotnet build
50+
51+
# Build specific project (note: full path to .csproj required)
52+
dotnet build src/OpenClaw.Tray/OpenClaw.Tray.csproj
53+
dotnet build src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj
3154
```
3255

3356
### Run Tray App
34-
```bash
35-
dotnet run --project src/OpenClaw.Tray
57+
58+
```powershell
59+
# WinForms version (.NET 10)
60+
dotnet run --project src/OpenClaw.Tray/OpenClaw.Tray.csproj
61+
62+
# WinUI version (.NET 9) - run the exe directly
63+
.\src\OpenClaw.Tray.WinUI\bin\Debug\net9.0-windows10.0.19041.0\OpenClaw.Tray.WinUI.exe
3664
```
3765

3866
## 📦 OpenClaw.Tray (Molty)

‎build.ps1‎

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
<#
2+
.SYNOPSIS
3+
Build script for OpenClaw Windows Hub
4+
5+
.DESCRIPTION
6+
Builds all projects, checks prerequisites, and provides clear guidance.
7+
8+
.PARAMETER Project
9+
Which project to build: All, Tray, WinUI, Shared, CommandPalette
10+
Default: All
11+
12+
.PARAMETER Configuration
13+
Build configuration: Debug, Release
14+
Default: Debug
15+
16+
.PARAMETER CheckOnly
17+
Only check prerequisites, don't build
18+
19+
.EXAMPLE
20+
.\build.ps1
21+
.\build.ps1 -Project WinUI -Configuration Release
22+
.\build.ps1 -CheckOnly
23+
#>
24+
25+
param(
26+
[ValidateSet("All", "Tray", "WinUI", "Shared", "CommandPalette")]
27+
[string]$Project = "All",
28+
29+
[ValidateSet("Debug", "Release")]
30+
[string]$Configuration = "Debug",
31+
32+
[switch]$CheckOnly
33+
)
34+
35+
$ErrorActionPreference = "Stop"
36+
37+
# Colors for output
38+
function Write-Header($text) { Write-Host "`n=== $text ===" -ForegroundColor Cyan }
39+
function Write-Success($text) { Write-Host "✅ $text" -ForegroundColor Green }
40+
function Write-Warning($text) { Write-Host "⚠️ $text" -ForegroundColor Yellow }
41+
function Write-Error($text) { Write-Host "❌ $text" -ForegroundColor Red }
42+
function Write-Info($text) { Write-Host " $text" -ForegroundColor Gray }
43+
44+
# Track issues
45+
$issues = @()
46+
47+
Write-Host @"
48+
49+
🦞 OpenClaw Windows Hub - Build Script
50+
=======================================
51+
52+
"@ -ForegroundColor Magenta
53+
54+
# =============================================================================
55+
# PREREQUISITE CHECKS
56+
# =============================================================================
57+
58+
Write-Header "Checking Prerequisites"
59+
60+
# Check OS
61+
if ($env:OS -ne "Windows_NT") {
62+
Write-Error "This project requires Windows"
63+
exit 1
64+
}
65+
Write-Success "Windows detected"
66+
67+
# Check .NET SDK
68+
$dotnetVersion = $null
69+
try {
70+
$dotnetVersion = & dotnet --version 2>$null
71+
} catch {}
72+
73+
if (-not $dotnetVersion) {
74+
Write-Error ".NET SDK not found"
75+
Write-Info "Download from: https://dotnet.microsoft.com/download"
76+
$issues += "Missing .NET SDK"
77+
} else {
78+
Write-Success ".NET SDK: $dotnetVersion"
79+
80+
# Check for .NET 10 (needed for WinForms tray)
81+
$sdks = & dotnet --list-sdks 2>$null
82+
$hasNet10 = $sdks | Where-Object { $_ -match "^10\." }
83+
$hasNet9 = $sdks | Where-Object { $_ -match "^9\." }
84+
85+
if (-not $hasNet10) {
86+
Write-Warning ".NET 10 SDK not found (needed for OpenClaw.Tray WinForms)"
87+
Write-Info "Download preview from: https://dotnet.microsoft.com/download/dotnet/10.0"
88+
$issues += "Missing .NET 10 SDK (for WinForms tray)"
89+
} else {
90+
Write-Success ".NET 10 SDK available"
91+
}
92+
93+
if (-not $hasNet9) {
94+
Write-Warning ".NET 9 SDK not found (needed for OpenClaw.Tray.WinUI)"
95+
Write-Info "Download from: https://dotnet.microsoft.com/download/dotnet/9.0"
96+
$issues += "Missing .NET 9 SDK (for WinUI tray)"
97+
} else {
98+
Write-Success ".NET 9 SDK available"
99+
}
100+
}
101+
102+
# Check Windows SDK (for WinUI)
103+
$windowsSdkPath = "${env:ProgramFiles(x86)}\Windows Kits\10\Include"
104+
if (Test-Path $windowsSdkPath) {
105+
$sdkVersions = Get-ChildItem $windowsSdkPath -Directory | Select-Object -ExpandProperty Name | Sort-Object -Descending
106+
Write-Success "Windows SDK: $($sdkVersions[0])"
107+
} else {
108+
Write-Warning "Windows 10 SDK not found (may be needed for WinUI)"
109+
Write-Info "Install via Visual Studio Installer or standalone SDK"
110+
$issues += "Windows 10 SDK not detected"
111+
}
112+
113+
# Check architecture
114+
$arch = $env:PROCESSOR_ARCHITECTURE
115+
Write-Success "Architecture: $arch"
116+
if ($arch -eq "ARM64") {
117+
Write-Info "ARM64 detected - builds will target ARM64 by default"
118+
}
119+
120+
# Summary
121+
Write-Header "Prerequisite Summary"
122+
123+
if ($issues.Count -eq 0) {
124+
Write-Success "All prerequisites met!"
125+
} else {
126+
Write-Warning "$($issues.Count) issue(s) found:"
127+
foreach ($issue in $issues) {
128+
Write-Info "- $issue"
129+
}
130+
}
131+
132+
if ($CheckOnly) {
133+
Write-Host "`nRun without -CheckOnly to build.`n"
134+
exit 0
135+
}
136+
137+
# =============================================================================
138+
# BUILD
139+
# =============================================================================
140+
141+
Write-Header "Building Projects ($Configuration)"
142+
143+
$buildResults = @{}
144+
145+
function Build-Project($name, $path) {
146+
Write-Host "`nBuilding $name..." -ForegroundColor White
147+
148+
if (-not (Test-Path $path)) {
149+
Write-Error "Project not found: $path"
150+
return $false
151+
}
152+
153+
$result = & dotnet build $path -c $Configuration 2>&1
154+
$exitCode = $LASTEXITCODE
155+
156+
if ($exitCode -eq 0) {
157+
Write-Success "$name built successfully"
158+
return $true
159+
} else {
160+
Write-Error "$name build failed"
161+
# Show relevant error lines
162+
$result | Select-String "error" | Select-Object -First 5 | ForEach-Object {
163+
Write-Info $_.Line
164+
}
165+
return $false
166+
}
167+
}
168+
169+
$projects = @{
170+
"Shared" = "src/OpenClaw.Shared/OpenClaw.Shared.csproj"
171+
"Tray" = "src/OpenClaw.Tray/OpenClaw.Tray.csproj"
172+
"WinUI" = "src/OpenClaw.Tray.WinUI/OpenClaw.Tray.WinUI.csproj"
173+
"CommandPalette" = "src/OpenClaw.CommandPalette/OpenClaw.CommandPalette.csproj"
174+
}
175+
176+
$toBuild = if ($Project -eq "All") { @("Shared", "Tray", "WinUI") } else { @($Project) }
177+
178+
# Always build Shared first if building other projects
179+
if ($Project -ne "Shared" -and $Project -ne "All" -and $toBuild -notcontains "Shared") {
180+
$toBuild = @("Shared") + $toBuild
181+
}
182+
183+
foreach ($proj in $toBuild) {
184+
if ($projects.ContainsKey($proj)) {
185+
$buildResults[$proj] = Build-Project $proj $projects[$proj]
186+
}
187+
}
188+
189+
# =============================================================================
190+
# SUMMARY
191+
# =============================================================================
192+
193+
Write-Header "Build Summary"
194+
195+
$successCount = ($buildResults.Values | Where-Object { $_ -eq $true }).Count
196+
$failCount = ($buildResults.Values | Where-Object { $_ -eq $false }).Count
197+
198+
foreach ($proj in $buildResults.Keys) {
199+
if ($buildResults[$proj]) {
200+
Write-Success "$proj"
201+
} else {
202+
Write-Error "$proj"
203+
}
204+
}
205+
206+
Write-Host ""
207+
if ($failCount -eq 0) {
208+
Write-Host "🦞 All builds succeeded!" -ForegroundColor Green
209+
210+
Write-Host "`nTo run:" -ForegroundColor Cyan
211+
if ($buildResults.ContainsKey("Tray") -or $buildResults.ContainsKey("All")) {
212+
Write-Host " WinForms: dotnet run --project src/OpenClaw.Tray/OpenClaw.Tray.csproj" -ForegroundColor White
213+
}
214+
if ($buildResults.ContainsKey("WinUI") -or $buildResults.ContainsKey("All")) {
215+
Write-Host " WinUI: .\src\OpenClaw.Tray.WinUI\bin\$Configuration\net9.0-windows10.0.19041.0\OpenClaw.Tray.WinUI.exe" -ForegroundColor White
216+
}
217+
} else {
218+
Write-Host "❌ $failCount build(s) failed" -ForegroundColor Red
219+
exit 1
220+
}
221+
222+
Write-Host ""

0 commit comments

Comments
 (0)