Utopia-Canteen-System/scripts/publish-backend.ps1

29 lines
946 B
PowerShell

# Publish UtopiaCanteen.BackendService to a folder (default C:\UtopiaCanteenBackend).
param(
[string]$OutputPath = "C:\UtopiaCanteenBackend",
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release"
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $PSScriptRoot
$Project = Join-Path $Root "UtopiaCanteen.BackendService\UtopiaCanteen.BackendService.csproj"
if (-not (Test-Path $Project)) {
throw "Project not found: $Project"
}
Write-Host "Publishing backend ($Configuration) -> $OutputPath"
dotnet publish $Project -c $Configuration -o $OutputPath --self-contained false
if ($LASTEXITCODE -ne 0) {
throw "dotnet publish failed with exit code $LASTEXITCODE"
}
$appsettings = Join-Path $OutputPath "appsettings.json"
if (Test-Path $appsettings) {
Write-Host "Edit connection strings in: $appsettings"
}
Write-Host "Done. Executable: $(Join-Path $OutputPath 'UtopiaCanteen.BackendService.exe')"