$ErrorActionPreference = "Stop"
$BinName = "xbp.exe"
$BuildPath = Join-Path (Resolve-Path ".") "target\release\$BinName"
$InstallDir = Join-Path $HOME ".cargo\bin"
cargo build --release
if (-not (Test-Path $BuildPath)) {
throw "Build failed: $BuildPath not found."
}
New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null
Copy-Item -Force $BuildPath (Join-Path $InstallDir $BinName)
Write-Host "Installed $BinName to $InstallDir"
Write-Host "Ensure $InstallDir is on your PATH."