[CmdletBinding()] param( [string]$PayloadRoot = "", [string]$OutputDir = "", [string]$IsccPath = "" ) $ErrorActionPreference = "Stop" $Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path if (-not $PayloadRoot) { $PayloadRoot = $Root } $PayloadRoot = (Resolve-Path $PayloadRoot).Path if (-not $OutputDir) { $OutputDir = Join-Path $Root "dist\installer" } New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null $OutputDir = (Resolve-Path $OutputDir).Path function Require-File([string]$RelativePath) { $path = Join-Path $PayloadRoot $RelativePath if (!(Test-Path $path -PathType Leaf)) { throw "Required installer payload file is missing: $path" } } Require-File "bin\jackailocald.exe" Require-File "backends\ollama\windows\ollama.exe" Require-File "webui\index.html" Require-File "webui\app-v15.js" Require-File "config\jackailocal.windows.toml" Require-File "START-DESKTOP.cmd" $modelFiles = @(Get-ChildItem -Path (Join-Path $PayloadRoot "models\ollama") -Recurse -File -ErrorAction SilentlyContinue | Where-Object { $_.Name -notlike "*.txt" }) if ($modelFiles.Count -eq 0) { throw "No real Ollama model files were found under models\ollama. Preload at least one model before building the installer." } if (-not $IsccPath) { $candidates = @( (Join-Path ${env:ProgramFiles(x86)} "Inno Setup 6\ISCC.exe"), (Join-Path $env:ProgramFiles "Inno Setup 6\ISCC.exe") ) $IsccPath = $candidates | Where-Object { $_ -and (Test-Path $_) } | Select-Object -First 1 } if (-not $IsccPath -or !(Test-Path $IsccPath)) { throw "Inno Setup 6 compiler was not found. Install Inno Setup or pass -IsccPath." } $iss = Join-Path $PSScriptRoot "JackAILocal.iss" & $IsccPath "/DPayloadRoot=$PayloadRoot" "/DOutputDir=$OutputDir" $iss if ($LASTEXITCODE -ne 0) { throw "Inno Setup failed with exit code $LASTEXITCODE." } $installer = Join-Path $OutputDir "JackAILocalSetup.exe" if (!(Test-Path $installer)) { throw "Installer was not created: $installer" } & (Join-Path $Root "factory\powershell\Sign-Executables.ps1") -Path $installer Write-Host "Real Windows installer created: $installer" -ForegroundColor Green