Updated publish script

This commit is contained in:
2026-02-02 17:46:48 +01:00
parent 30b0bf8481
commit f149d1bc07

View File

@@ -1,7 +1,7 @@
# Hard-coded deploy settings. Fill these in before running. # Hard-coded deploy settings. Fill these in before running.
$FtpHost = "xTr1m.com" $FtpHost = "xTr1m.com"
$FtpUser = "xTr1m" $FtpUser = "xTr1m"
$FtpPassword = $null # prompted at runtime $Password = $null # prompted at runtime
$RemoteDir = "/httpdocs/picknplay" $RemoteDir = "/httpdocs/picknplay"
$ProjectPath = "..\\GameList.csproj" $ProjectPath = "..\\GameList.csproj"
$Configuration = "Release" $Configuration = "Release"
@@ -13,7 +13,6 @@ $RecycleAppPool = $true
$AppPoolName = "xTr1m.com(domain)(4.0)(pool)" $AppPoolName = "xTr1m.com(domain)(4.0)(pool)"
$WinRmComputer = "xTr1m.com" $WinRmComputer = "xTr1m.com"
$WinRmCredentialUser = "Administrator" $WinRmCredentialUser = "Administrator"
$WinRmCredentialPass = $null # prompted at runtime
$UseWinRmHttps = $true # set false if using HTTP + TrustedHosts $UseWinRmHttps = $true # set false if using HTTP + TrustedHosts
<#! <#!
@@ -60,9 +59,8 @@ function Read-PlainOrPrompt([object]$Value, [string]$Prompt, [bool]$Secure = $fa
return Read-Host -Prompt $Prompt return Read-Host -Prompt $Prompt
} }
$FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" $true $Password = Read-PlainOrPrompt $Password "Password" $true
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" $true $WinRmAuth = "Basic" # Basic for local admin over HTTPS; use Default/Kerberos if joined to domain
$WinRmAuth = "Basic" # Basic for local admin over HTTPS; use Default/Kerberos if joined to domain
Write-Host "1) Publishing..." -ForegroundColor Cyan Write-Host "1) Publishing..." -ForegroundColor Cyan
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue } if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue }
@@ -73,7 +71,7 @@ dotnet @publishArgs
if ($RecycleAppPool) { if ($RecycleAppPool) {
Write-Host "2) Stopping IIS app pool via WinRM..." -ForegroundColor Cyan Write-Host "2) Stopping IIS app pool via WinRM..." -ForegroundColor Cyan
$sec = ConvertTo-SecureString $WinRmCredentialPass -AsPlainText -Force $sec = ConvertTo-SecureString $Password -AsPlainText -Force
$cred = New-Object pscredential($WinRmCredentialUser, $sec) $cred = New-Object pscredential($WinRmCredentialUser, $sec)
$invokeParams = @{ $invokeParams = @{
ComputerName = $WinRmComputer ComputerName = $WinRmComputer
@@ -97,7 +95,7 @@ $tempScript = New-TemporaryFile
@" @"
option batch continue option batch continue
option confirm off option confirm off
open ftp://$($FtpUser):$($FtpPassword.Replace('`n','').Replace('`r',''))@$FtpHost open ftp://$($FtpUser):$($Password.Replace('`n','').Replace('`r',''))@$FtpHost
lcd $PublishDir lcd $PublishDir
cd $RemoteDir cd $RemoteDir
synchronize remote . -delete -filemask="|web.config" synchronize remote . -delete -filemask="|web.config"
@@ -109,7 +107,7 @@ Remove-Item $tempScript -ErrorAction SilentlyContinue
if ($RecycleAppPool) { if ($RecycleAppPool) {
Write-Host "4) Starting IIS app pool via WinRM..." -ForegroundColor Cyan Write-Host "4) Starting IIS app pool via WinRM..." -ForegroundColor Cyan
$sec = ConvertTo-SecureString $WinRmCredentialPass -AsPlainText -Force $sec = ConvertTo-SecureString $Password -AsPlainText -Force
$cred = New-Object pscredential($WinRmCredentialUser, $sec) $cred = New-Object pscredential($WinRmCredentialUser, $sec)
$invokeParams = @{ $invokeParams = @{
ComputerName = $WinRmComputer ComputerName = $WinRmComputer