<# .SYNOPSIS Build & package SpdUp – Gaming Booster .DESCRIPTION 1. Publishes the app as self-contained (win-x64) 2. Optionally compiles the Inno Setup installer into a single .exe .EXAMPLE .\build-installer.ps1 # Publish only .\build-installer.ps1 -Installer # Publish + compile installer #> param( [switch]$Installer, [string]$Configuration = "Release" ) $ErrorActionPreference = "Stop" $root = $PSScriptRoot $proj = Join-Path $root "SpdUp.csproj" $pubDir = Join-Path $root "publish\SpdUp" $issFile = Join-Path $root "Installer\SpdUpSetup.iss" # ── Step 1: Clean previous publish ──────────────────────── Write-Host "`n=== Cleaning previous publish ===" -ForegroundColor Cyan if (Test-Path $pubDir) { Remove-Item $pubDir -Recurse -Force } # ── Step 2: Publish self-contained ──────────────────────── Write-Host "`n=== Publishing SpdUp (self-contained, win-x64, $Configuration) ===" -ForegroundColor Cyan dotnet publish $proj ` -c $Configuration ` -r win-x64 ` --self-contained true ` -o $pubDir if ($LASTEXITCODE -ne 0) { Write-Error "dotnet publish failed with exit code $LASTEXITCODE" exit 1 } $files = Get-ChildItem $pubDir -Recurse -File $totalMB = [math]::Round(($files | Measure-Object -Property Length -Sum).Sum / 1MB, 1) Write-Host "`nPublished $($files.Count) files ($totalMB MB) to: $pubDir" -ForegroundColor Green # ── Step 3 (optional): Compile Inno Setup installer ────── if ($Installer) { Write-Host "`n=== Compiling Inno Setup installer ===" -ForegroundColor Cyan # Try to find ISCC.exe (Inno Setup Compiler) $isccPaths = @( "${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "${env:ProgramFiles}\Inno Setup 6\ISCC.exe", "${env:ProgramFiles(x86)}\Inno Setup 5\ISCC.exe" ) $iscc = $isccPaths | Where-Object { Test-Path $_ } | Select-Object -First 1 if (-not $iscc) { Write-Host "" Write-Warning "Inno Setup not found! Install it from: https://jrsoftware.org/isdl.php" Write-Host "After installing, run this script again with -Installer" -ForegroundColor Yellow Write-Host "`nAlternatively, open '$issFile' directly in Inno Setup and click Compile." -ForegroundColor Yellow exit 1 } Write-Host "Using: $iscc" & $iscc $issFile if ($LASTEXITCODE -ne 0) { Write-Error "Inno Setup compilation failed with exit code $LASTEXITCODE" exit 1 } $setupExe = Get-ChildItem (Join-Path $root "publish") -Filter "SpdUp_Setup_*.exe" | Select-Object -First 1 if ($setupExe) { $sizeMB = [math]::Round($setupExe.Length / 1MB, 1) Write-Host "`nInstaller created: $($setupExe.FullName) ($sizeMB MB)" -ForegroundColor Green } } else { Write-Host "`n=== Skipping installer (use -Installer to compile setup.exe) ===" -ForegroundColor Yellow Write-Host "To create the installer, either:" Write-Host " 1. Run: .\build-installer.ps1 -Installer" Write-Host " 2. Install Inno Setup 6, open '$issFile', click Compile" } Write-Host "`nDone!" -ForegroundColor Green