From bc0245c1d40e554ac9f99387f2f625ef03e992c1 Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Sun, 8 Feb 2026 22:40:29 +0100 Subject: [PATCH] Fix deploy password prompt and WinRM app pool args --- scripts/deploy-ftp.ps1 | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/scripts/deploy-ftp.ps1 b/scripts/deploy-ftp.ps1 index 1c68717..bdea593 100644 --- a/scripts/deploy-ftp.ps1 +++ b/scripts/deploy-ftp.ps1 @@ -146,8 +146,18 @@ $recycleAppPool = $recycleAppPool -and -not $SkipRecycle $runEfMigrations = $runEfMigrations -and -not $SkipMigrations $passwordFromEnv = $env:PICKNPLAY_FTP_PASSWORD -$passwordForSession = if ($useStoredSession) { "" } else { Read-PlainOrPrompt -Value ($Password ?? $passwordFromEnv) -Prompt "FTP password" -Secure $true } -$passwordForWinRm = if ($recycleAppPool -or $runEfMigrations) { Read-PlainOrPrompt -Value ($Password ?? $passwordFromEnv) -Prompt "WinRM password" -Secure $true } else { "" } +$passwordFromInput = if (-not [string]::IsNullOrWhiteSpace($Password)) { $Password } else { $passwordFromEnv } +$needsFtpPassword = -not $useStoredSession +$needsWinRmPassword = $recycleAppPool -or $runEfMigrations +$sharedPassword = "" + +if ($needsFtpPassword -or $needsWinRmPassword) { + $prompt = if ($needsFtpPassword -and $needsWinRmPassword) { "FTP/WinRM password" } elseif ($needsFtpPassword) { "FTP password" } else { "WinRM password" } + $sharedPassword = Read-PlainOrPrompt -Value $passwordFromInput -Prompt $prompt -Secure $true +} + +$passwordForSession = if ($needsFtpPassword) { $sharedPassword } else { "" } +$passwordForWinRm = if ($needsWinRmPassword) { $sharedPassword } else { "" } Assert-Tool "dotnet" Assert-Tool $winScpPath @@ -166,14 +176,16 @@ dotnet @publishArgs if ($recycleAppPool) { Require-ConfigValue $config "AppPoolName" + $appPoolName = [string]$config.AppPoolName Write-Host "2) Stopping IIS app pool via WinRM..." -ForegroundColor Cyan try { Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock { + param($poolName) Import-Module WebAdministration - Stop-WebAppPool -Name $using:AppPoolName -ErrorAction SilentlyContinue + Stop-WebAppPool -Name $poolName -ErrorAction SilentlyContinue Get-Process GameList -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue Get-Process dotnet -ErrorAction SilentlyContinue | Where-Object { $_.Path -like "*picknplay*" } | Stop-Process -Force -ErrorAction SilentlyContinue - } + } -ArgumentList @($appPoolName) } catch { Write-Warning "WinRM stop failed: $($_.Exception.Message)." @@ -209,9 +221,10 @@ if ($recycleAppPool) { Write-Host "4) Starting IIS app pool via WinRM..." -ForegroundColor Cyan try { Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock { + param($poolName) Import-Module WebAdministration - Start-WebAppPool -Name $using:AppPoolName - } + Start-WebAppPool -Name $poolName + } -ArgumentList @($appPoolName) } catch { Write-Warning "WinRM start failed: $($_.Exception.Message)."