# ============================================================ # Omika Diagnostics — Publication des composants serveur (poste DEV) # ============================================================ # Usage (depuis le poste de développement, SDK .NET 10 installé) : # .\scripts\publish-diagnostics.ps1 # .\scripts\publish-diagnostics.ps1 -OutputRoot D:\Omika\Deploy # .\scripts\publish-diagnostics.ps1 -IncludeCentralApi # ajoute Omika.Diagnostics.Api # .\scripts\publish-diagnostics.ps1 -SkipDevelopmentJsonCheck # # Produit, pour chaque composant, un dossier "-next" contenant la # publication Release win-x64 framework-dependent, et vérifie la présence de # l'exécutable attendu (stop en cas d'absence). # # Les dossiers produits sont ensuite transférés vers SRV-OMIKA puis copiés avec # robocopy /E /XF appsettings.json appsettings.Production.json (voir # docs/MISE_A_JOUR_DIAGNOSTICS_SRV-OMIKA.md). # # Ne fait AUCUNE copie vers le serveur, ne touche à AUCUN secret. # ============================================================ [CmdletBinding()] param( [string]$OutputRoot = 'C:\Omika\Deploy', [switch]$IncludeCentralApi, [switch]$SkipDevelopmentJsonCheck ) $ErrorActionPreference = 'Stop' # Racine du dépôt = parent du dossier scripts\. $RepoRoot = Split-Path -Parent $PSScriptRoot $components = @( @{ Name = 'OmikaApi' Proj = 'src\Omika.Api\Omika.Api.csproj' Exe = 'Omika.Api.exe' }, @{ Name = 'OmikaWorker' Proj = 'src\Omika.Worker\Omika.Worker.csproj' Exe = 'Omika.Worker.exe' }, @{ Name = 'DiagnosticsWorker' Proj = 'src\Omika.Diagnostics.Worker\Omika.Diagnostics.Worker.csproj' Exe = 'Omika.Diagnostics.Worker.exe' }, @{ Name = 'DiagnosticsWeb' Proj = 'src\Omika.Diagnostics.Web\Omika.Diagnostics.Web.csproj' Exe = 'Omika.Diagnostics.Web.exe' } ) if ($IncludeCentralApi) { $components += @{ Name = 'DiagnosticsApi' Proj = 'src\Omika.Diagnostics.Api\Omika.Diagnostics.Api.csproj' Exe = 'Omika.Diagnostics.Api.exe' } } Write-Host '== Publication Omika Diagnostics (Release win-x64, framework-dependent) ==' -ForegroundColor Cyan foreach ($c in $components) { $out = Join-Path $OutputRoot ($c.Name + '-next') $proj = Join-Path $RepoRoot $c.Proj if (-not (Test-Path -LiteralPath $proj)) { throw "Projet introuvable : $proj" } Write-Host '' Write-Host "== $($c.Name) -> $out ==" -ForegroundColor Cyan # -r win-x64 --self-contained false : framework-dependent (runtime .NET 10 requis # sur le serveur). Le Worker conserve EnableWindowsService=true (défaut) : ne pas # passer -p:EnableWindowsService=false pour un publish Release+RID. dotnet publish $proj ` -c Release ` -r win-x64 ` --self-contained false ` -o $out if ($LASTEXITCODE -ne 0) { throw "dotnet publish a échoué (exit $LASTEXITCODE) sur $($c.Name)." } $exe = Join-Path $out $c.Exe if (-not (Test-Path -LiteralPath $exe)) { throw "Exécutable attendu absent : $exe" } Write-Host " OK : $exe" -ForegroundColor Green if (-not $SkipDevelopmentJsonCheck) { $devJson = Join-Path $out 'appsettings.Development.json' if (Test-Path -LiteralPath $devJson) { Write-Warning " appsettings.Development.json présent dans la publication ($($c.Name)) : ne pas l'activer en Production (ASPNETCORE_ENVIRONMENT doit rester 'Production')." } } } Write-Host '' Write-Host 'Publication terminée.' -ForegroundColor Green Write-Host "Dossiers produits (à transférer vers SRV-OMIKA C:\Omika\Deploy\) :" foreach ($c in $components) { Write-Host " $((Join-Path $OutputRoot ($c.Name + '-next')))" } Write-Host '' Write-Host 'Rappel copie serveur (après backup + arrêt) :' -ForegroundColor Yellow Write-Host " robocopy '-next' 'C:\Omika\Apps\' /E /XF appsettings.json appsettings.Production.json"