param([int]$Port = 15199) $ErrorActionPreference = 'Stop' $taskRepo = Split-Path $PSScriptRoot -Parent $taskRunDir = Join-Path ([IO.Path]::GetTempPath()) ('ikar-admin-ui-' + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $taskRunDir | Out-Null Copy-Item -LiteralPath "$taskRepo/ikar_server/src/Ikar.Server/wwwroot" -Destination $taskRunDir -Recurse Copy-Item -LiteralPath "$taskRepo/ikar_server/src/Ikar.Server/bin/Debug/net10.0" -Destination "$taskRunDir/runtime" -Recurse $taskEnvironment = @{ ASPNETCORE_ENVIRONMENT = 'Development' ASPNETCORE_URLS = "http://127.0.0.1:$Port" SeedDemoData = 'false' ConnectionStrings__IkarDb = "Data Source=$taskRunDir/Data/ikar.db;Pooling=False" Admin__Username = 'admin-test' Admin__Password = 'test-only-password' IkarUpdates__LocalOnly = 'true' Logging__LogLevel__Default = 'Warning' } $taskProcess = Start-Process -FilePath dotnet -ArgumentList @("$taskRunDir/runtime/Ikar.Server.dll") -WorkingDirectory $taskRunDir -WindowStyle Hidden -RedirectStandardOutput "$taskRunDir/server.stdout.log" -RedirectStandardError "$taskRunDir/server.stderr.log" -Environment $taskEnvironment -PassThru $taskReady = $false for ($taskAttempt = 0; $taskAttempt -lt 30; $taskAttempt++) { if ($taskProcess.HasExited) { throw "Test server exited; inspect $taskRunDir/server.stderr.log" } try { $taskHealth = Invoke-RestMethod -Uri "http://127.0.0.1:$Port/health" -TimeoutSec 2; if ($taskHealth.status -eq 'ok') { $taskReady = $true; break } } catch { } Start-Sleep -Milliseconds 500 } if (!$taskReady) { Stop-Process -Id $taskProcess.Id; throw 'Test server did not become healthy' } @{pid=$taskProcess.Id;root=$taskRunDir;url="http://127.0.0.1:$Port"} | ConvertTo-Json | Set-Content "$taskRepo/artifacts/admin-local-server.json" Get-Content "$taskRepo/artifacts/admin-local-server.json"