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

55 lines
1.8 KiB
PowerShell

# Publish UtopiaCanteen.Client (WPF scanner) to a folder (default C:\UtopiaCanteenClient).
# Default: self-contained win-x64 (no .NET runtime required on target PC).
param(
[string]$OutputPath = "C:\UtopiaCanteenClient",
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release",
[string]$Runtime = "win-x64",
[switch]$FrameworkDependent,
[switch]$SelfContained
)
$ErrorActionPreference = "Stop"
$Root = Split-Path -Parent $PSScriptRoot
$Project = Join-Path $Root "UtopiaCanteen.Client\UtopiaCanteen.Client.csproj"
if (-not (Test-Path $Project)) {
throw "Project not found: $Project"
}
$isSelfContained = -not $FrameworkDependent
if ($SelfContained) {
$isSelfContained = $true
}
$publishArgs = @(
"publish", $Project,
"-c", $Configuration,
"-o", $OutputPath
)
if ($isSelfContained) {
$publishArgs += @("-r", $Runtime, "--self-contained", "true")
Write-Host "Publishing client ($Configuration, self-contained $Runtime) -> $OutputPath"
} else {
$publishArgs += @("--self-contained", "false")
Write-Host "Publishing client ($Configuration, framework-dependent) -> $OutputPath"
Write-Host "Target PC must have .NET 8 Desktop Runtime installed."
}
dotnet @publishArgs
if ($LASTEXITCODE -ne 0) {
throw "dotnet publish failed with exit code $LASTEXITCODE"
}
Write-Host @"
Done. Run: $(Join-Path $OutputPath 'UtopiaCanteen.Client.exe')
Deploy: copy the entire folder '$OutputPath' to each scanner PC (or your file share).
$(if ($isSelfContained) { "Self-contained: .NET runtime is included; no separate install needed." } else { "Framework-dependent: install .NET 8 Desktop Runtime on each PC." })
First run: open Settings and set Backend base URL (e.g. http://192.168.1.10:5000).
Config file: %LocalAppData%\UtopiaCanteenClient\appsettings.json
"@