Make publish scripts self-contained by default

Update backend and client publish scripts to produce win-x64 self-contained builds unless framework-dependent publishing is explicitly requested. Add runtime selection, clearer publish output, and deployment notes for target machines.
feature/centralized-offline-canteen
SYED MUSTUFA AHMED NAQVI 2026-07-13 14:03:12 +05:00
parent 95c8ac7f63
commit 688ef2afd3
2 changed files with 62 additions and 7 deletions

View File

@ -1,8 +1,12 @@
# Publish UtopiaCanteen.BackendService to a folder (default C:\UtopiaCanteenBackend).
# Default: self-contained win-x64 (no .NET runtime required on target PC).
param(
[string]$OutputPath = "C:\UtopiaCanteenBackend",
[ValidateSet("Debug", "Release")]
[string]$Configuration = "Release"
[string]$Configuration = "Release",
[string]$Runtime = "win-x64",
[switch]$FrameworkDependent,
[switch]$SelfContained
)
$ErrorActionPreference = "Stop"
@ -13,8 +17,28 @@ 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
# Self-contained unless -FrameworkDependent is passed.
$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 backend ($Configuration, self-contained $Runtime) -> $OutputPath"
} else {
$publishArgs += @("--self-contained", "false")
Write-Host "Publishing backend ($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"
@ -25,4 +49,9 @@ if (Test-Path $appsettings) {
Write-Host "Edit connection strings in: $appsettings"
}
Write-Host "Done. Executable: $(Join-Path $OutputPath 'UtopiaCanteen.BackendService.exe')"
Write-Host @"
Done. Executable: $(Join-Path $OutputPath 'UtopiaCanteen.BackendService.exe')
Deploy: copy the entire folder '$OutputPath' to the server PC.
$(if ($isSelfContained) { "Self-contained: .NET runtime is included; no separate install needed." } else { "Framework-dependent: install .NET 8 Runtime on the server." })
"@

View File

@ -1,8 +1,12 @@
# 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]$Configuration = "Release",
[string]$Runtime = "win-x64",
[switch]$FrameworkDependent,
[switch]$SelfContained
)
$ErrorActionPreference = "Stop"
@ -13,8 +17,27 @@ if (-not (Test-Path $Project)) {
throw "Project not found: $Project"
}
Write-Host "Publishing client ($Configuration) -> $OutputPath"
dotnet publish $Project -c $Configuration -o $OutputPath --self-contained false
$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"
@ -23,6 +46,9 @@ if ($LASTEXITCODE -ne 0) {
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
"@