mirror of
https://github.com/wwiinnddyy/LanMountainDesktop.git
synced 2026-06-20 15:44:25 +08:00
Introduce a persistent LauncherDebugSettingsStore and wire it into ErrorWindow and SplashWindow so dev-mode and custom host path can be saved/loaded. Harden DeploymentLocator/FlexibleHostLocator to safely normalize and validate saved debug paths and log warnings for malformed values. Add a WaitingForShell startup state and recoverable-activation logic across App and LauncherFlowCoordinator (with registry updates) so Launcher can attach to an in-progress desktop shell rather than failing. Clean up ErrorDebugWindow UI/flow (WasAccepted flag, localization fixes, event wiring) and improve splash version population. Improve AppVersionProvider to trim surrounding quotes, robustly parse version.json via JsonDocument and read string properties; add unit tests for AppVersionProvider, DeploymentLocator and LauncherDebugSettingsStore. Also quote Exec commands in the csproj and harden scripts/Generate-VersionFile.ps1 (argument normalization, LiteralPath, error handling).
65 lines
1.6 KiB
PowerShell
65 lines
1.6 KiB
PowerShell
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$OutputPath,
|
|
|
|
[Parameter(Mandatory=$true)]
|
|
[string]$Version,
|
|
|
|
[Parameter(Mandatory=$false)]
|
|
[string]$Codename = "Administrate"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Normalize-ArgumentValue {
|
|
param(
|
|
[Parameter(Mandatory=$true)]
|
|
[AllowEmptyString()]
|
|
[string]$Value
|
|
)
|
|
|
|
$trimmed = $Value.Trim()
|
|
if ($trimmed.Length -ge 2) {
|
|
$first = $trimmed[0]
|
|
$last = $trimmed[$trimmed.Length - 1]
|
|
if (($first -eq "'" -and $last -eq "'") -or ($first -eq '"' -and $last -eq '"')) {
|
|
return $trimmed.Substring(1, $trimmed.Length - 2).Trim()
|
|
}
|
|
}
|
|
|
|
return $trimmed
|
|
}
|
|
|
|
$OutputPath = Normalize-ArgumentValue -Value $OutputPath
|
|
$Version = Normalize-ArgumentValue -Value $Version
|
|
$Codename = Normalize-ArgumentValue -Value $Codename
|
|
|
|
if ([string]::IsNullOrWhiteSpace($OutputPath)) {
|
|
throw "OutputPath is required."
|
|
}
|
|
|
|
if ([string]::IsNullOrWhiteSpace($Version)) {
|
|
throw "Version is required."
|
|
}
|
|
|
|
$versionInfo = @{
|
|
Version = $Version
|
|
Codename = $Codename
|
|
}
|
|
|
|
$json = $versionInfo | ConvertTo-Json -Compress
|
|
$dir = Split-Path -Parent $OutputPath
|
|
|
|
if ([string]::IsNullOrWhiteSpace($dir)) {
|
|
throw "OutputPath must include a directory: $OutputPath"
|
|
}
|
|
|
|
if (!(Test-Path -LiteralPath $dir)) {
|
|
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
|
}
|
|
|
|
Set-Content -LiteralPath $OutputPath -Value $json -Encoding UTF8
|
|
Write-Host "Generated version file: $OutputPath" -ForegroundColor Green
|
|
Write-Host " Version: $Version" -ForegroundColor Gray
|
|
Write-Host " Codename: $Codename" -ForegroundColor Gray
|