<# Baut den Update-Agent als eigenstaendige Installer-Binaries und legt sie samt Pruefsummen, Manifest und Bootstrap-Skripten zum Upload bereit. pwsh scripts/build_installer.ps1 python scripts/upload_installer.py .\artifacts\installer Selbstenthaltend und als Einzeldatei: Auf einem frisch aufgesetzten Zielsystem ist keine .NET-Laufzeit vorhanden, und ein Installer, der erst eine Laufzeit nachinstalliert, hat sein Versprechen schon gebrochen. Bewusst OHNE NativeAOT und ohne Trimming: Spectre.Console loest seine Eingabeaufforderungen ueber Reflexion auf. Getrimmt baut das zwar, bricht aber erst beim Anwender - ein groesseres Binary ist der bessere Handel. #> param( [string] $Version = '2.3.0', [string] $OutputDir = (Join-Path $PSScriptRoot '..\artifacts\installer'), [string[]] $Runtimes = @('win-x64', 'linux-x64', 'linux-arm64') ) $ErrorActionPreference = 'Stop' $repoRoot = Resolve-Path (Join-Path $PSScriptRoot '..') $project = Join-Path $repoRoot 'client-dotnet\Deploymentcenter.UpdateAgent\Deploymentcenter.UpdateAgent.csproj' $staging = Join-Path ([System.IO.Path]::GetTempPath()) ("dc-installer-build-" + [guid]::NewGuid().ToString('N')) if (-not (Test-Path $project)) { throw "Projekt nicht gefunden: $project" } New-Item -ItemType Directory -Force -Path $OutputDir | Out-Null Get-ChildItem $OutputDir -File | Remove-Item -Force $gitCommit = 'UNKNOWN' try { $gitCommit = (git -C $repoRoot rev-parse --short HEAD).Trim() } catch { } $binaries = @() try { foreach ($rid in $Runtimes) { Write-Host "Baue $rid ..." -ForegroundColor Cyan $ridOut = Join-Path $staging $rid dotnet publish $project ` -c Release -r $rid ` --self-contained true ` -p:PublishSingleFile=true ` -p:EnableCompressionInSingleFile=true ` -p:DebugType=None ` -o $ridOut ` -v q --nologo if ($LASTEXITCODE -ne 0) { throw "dotnet publish fuer $rid ist fehlgeschlagen." } $isWindows = $rid.StartsWith('win') $sourceName = if ($isWindows) { 'update-agent.exe' } else { 'update-agent' } $targetName = if ($isWindows) { "update-agent-$rid.exe" } else { "update-agent-$rid" } $source = Join-Path $ridOut $sourceName $target = Join-Path $OutputDir $targetName Copy-Item $source $target -Force $hash = (Get-FileHash $target -Algorithm SHA256).Hash.ToLower() $size = (Get-Item $target).Length # Die Pruefsumme liegt als eigene Datei daneben, damit install.sh sie # ohne JSON-Parser lesen kann. [System.IO.File]::WriteAllText("$target.sha256", $hash) $binaries += [ordered]@{ platform = $rid file = $targetName sha256 = $hash sizeBytes = $size } Write-Host (" {0,-22} {1,6:N1} MB {2}" -f $targetName, ($size / 1MB), $hash.Substring(0, 16)) } $manifest = [ordered]@{ tool = 'update-agent' version = $Version gitCommit = $gitCommit buildDateUtc = (Get-Date).ToUniversalTime().ToString('o') binaries = $binaries } # Bewusst ueber WriteAllText mit einer BOM-freien Kodierung: Out-File # -Encoding utf8 stellt unter Windows PowerShell 5.1 ein BOM voran, und # PHPs json_decode() scheitert daran. Die Downloadseite haette dann # dauerhaft "noch nichts hinterlegt" gemeldet. $utf8NoBom = New-Object System.Text.UTF8Encoding($false) [System.IO.File]::WriteAllText( (Join-Path $OutputDir 'installer.json'), ($manifest | ConvertTo-Json -Depth 5), $utf8NoBom) # Die Bootstrap-Skripte liegen versioniert im Repository und werden hier # nur mitgenommen. foreach ($script in @('install.sh', 'install.ps1')) { $path = Join-Path $repoRoot "scripts\installer\$script" if (Test-Path $path) { Copy-Item $path (Join-Path $OutputDir $script) -Force } else { Write-Warning "$script nicht gefunden unter scripts\installer\ - wird nicht mit ausgeliefert." } } Write-Host '' Write-Host "Fertig. Ergebnis in $OutputDir" -ForegroundColor Green Write-Host "Hochladen mit: python scripts/upload_installer.py `"$OutputDir`"" } finally { Remove-Item -Recurse -Force $staging -ErrorAction SilentlyContinue }