Fix deploy password prompt and WinRM app pool args

This commit is contained in:
2026-02-08 22:40:29 +01:00
parent 6eea5dcf32
commit bc0245c1d4

View File

@@ -146,8 +146,18 @@ $recycleAppPool = $recycleAppPool -and -not $SkipRecycle
$runEfMigrations = $runEfMigrations -and -not $SkipMigrations $runEfMigrations = $runEfMigrations -and -not $SkipMigrations
$passwordFromEnv = $env:PICKNPLAY_FTP_PASSWORD $passwordFromEnv = $env:PICKNPLAY_FTP_PASSWORD
$passwordForSession = if ($useStoredSession) { "" } else { Read-PlainOrPrompt -Value ($Password ?? $passwordFromEnv) -Prompt "FTP password" -Secure $true } $passwordFromInput = if (-not [string]::IsNullOrWhiteSpace($Password)) { $Password } else { $passwordFromEnv }
$passwordForWinRm = if ($recycleAppPool -or $runEfMigrations) { Read-PlainOrPrompt -Value ($Password ?? $passwordFromEnv) -Prompt "WinRM password" -Secure $true } else { "" } $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 "dotnet"
Assert-Tool $winScpPath Assert-Tool $winScpPath
@@ -166,14 +176,16 @@ dotnet @publishArgs
if ($recycleAppPool) { if ($recycleAppPool) {
Require-ConfigValue $config "AppPoolName" Require-ConfigValue $config "AppPoolName"
$appPoolName = [string]$config.AppPoolName
Write-Host "2) Stopping IIS app pool via WinRM..." -ForegroundColor Cyan Write-Host "2) Stopping IIS app pool via WinRM..." -ForegroundColor Cyan
try { try {
Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock { Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock {
param($poolName)
Import-Module WebAdministration 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 GameList -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process dotnet -ErrorAction SilentlyContinue | Where-Object { $_.Path -like "*picknplay*" } | Stop-Process -Force -ErrorAction SilentlyContinue Get-Process dotnet -ErrorAction SilentlyContinue | Where-Object { $_.Path -like "*picknplay*" } | Stop-Process -Force -ErrorAction SilentlyContinue
} } -ArgumentList @($appPoolName)
} }
catch { catch {
Write-Warning "WinRM stop failed: $($_.Exception.Message)." Write-Warning "WinRM stop failed: $($_.Exception.Message)."
@@ -209,9 +221,10 @@ if ($recycleAppPool) {
Write-Host "4) Starting IIS app pool via WinRM..." -ForegroundColor Cyan Write-Host "4) Starting IIS app pool via WinRM..." -ForegroundColor Cyan
try { try {
Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock { Invoke-WinRmScript -Config $config -PasswordValue $passwordForWinRm -ScriptBlock {
param($poolName)
Import-Module WebAdministration Import-Module WebAdministration
Start-WebAppPool -Name $using:AppPoolName Start-WebAppPool -Name $poolName
} } -ArgumentList @($appPoolName)
} }
catch { catch {
Write-Warning "WinRM start failed: $($_.Exception.Message)." Write-Warning "WinRM start failed: $($_.Exception.Message)."