[CmdletBinding()] param([Parameter(Mandatory=$true)][string]$Output, [string]$Services='all') $ErrorActionPreference='Stop' $assemblies=@{ 'api-gateway'='ApiGateway'; 'patient-profile'='PatientProfileService'; 'observation'='ObservationService'; 'insights'='InsightsService'; 'health-overview'='HealthOverviewService' } $selected=if ($Services -eq 'all') { @('api-gateway','patient-profile','observation','insights','health-overview') } else { @($Services.Split(',')) } if ((Test-Path $Output) -or @($selected | Select-Object -Unique).Count -ne $selected.Count) { throw 'Use a new output directory and unique service names.' } foreach ($name in $selected) { if (-not $assemblies.ContainsKey($name)) { throw "Unknown service: $name" } } New-Item -ItemType Directory -Path $Output | Out-Null $destination=(Resolve-Path $Output).Path $repository=Split-Path $PSScriptRoot -Parent foreach ($directory in @('services','systemd','examples')) { New-Item -ItemType Directory -Path "$destination\$directory" | Out-Null } Copy-Item "$PSScriptRoot\installer\*.sh","$PSScriptRoot\installer\*.ps1","$PSScriptRoot\INSTALLATION.md" $destination foreach ($name in $selected) { & dotnet publish "$repository\src\$($assemblies[$name])\$($assemblies[$name]).csproj" --configuration Release --self-contained false '-p:UseAppHost=false' --output "$destination\services\$name" if ($LASTEXITCODE -ne 0) { throw "Publish failed: $name" } Copy-Item "$PSScriptRoot\systemd\healthapp-$name.service" "$destination\systemd" Copy-Item "$PSScriptRoot\$name.env.example" "$destination\examples" } & dotnet publish "$PSScriptRoot\HealthApp.Provisioning\HealthApp.Provisioning.csproj" --configuration Release --self-contained false '-p:UseAppHost=false' --output "$destination\provisioner" if ($LASTEXITCODE -ne 0) { throw 'Publish failed: provisioning utility' } $selected | Set-Content "$destination\services.list" Write-Host "Portable release created: $destination"