Publish to temp dir to avoid recursive copies
This commit is contained in:
@@ -6,7 +6,7 @@ $RemoteDir = "/httpdocs/picknplay"
|
|||||||
$ProjectPath = "..\\GameList.csproj"
|
$ProjectPath = "..\\GameList.csproj"
|
||||||
$Configuration = "Release"
|
$Configuration = "Release"
|
||||||
$Runtime = "win-x64"
|
$Runtime = "win-x64"
|
||||||
$PublishDir = "..\\artifacts\\publish"
|
$PublishDir = "$env:TEMP\\GameList-publish"
|
||||||
$SelfContained = $false
|
$SelfContained = $false
|
||||||
$WinScpPath = "C:\\Users\\frank\\AppData\\Local\\Programs\\WinSCP\\WinSCP.com"
|
$WinScpPath = "C:\\Users\\frank\\AppData\\Local\\Programs\\WinSCP\\WinSCP.com"
|
||||||
$RecycleAppPool = $true
|
$RecycleAppPool = $true
|
||||||
@@ -50,11 +50,8 @@ Assert-Tool $WinScpPath
|
|||||||
function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $false) {
|
function Read-PlainOrPrompt([string]$Value, [string]$Prompt, [bool]$Secure = $false) {
|
||||||
if ($Value) { return $Value }
|
if ($Value) { return $Value }
|
||||||
if ($Secure) {
|
if ($Secure) {
|
||||||
$secure = Read-Host -Prompt $Prompt -AsSecureString
|
$pwd = Read-Host -Prompt $Prompt -AsSecureString
|
||||||
if (-not ($secure -is [System.Security.SecureString])) {
|
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($pwd)
|
||||||
$secure = ConvertTo-SecureString -String ([string]$secure) -AsPlainText -Force
|
|
||||||
}
|
|
||||||
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
|
|
||||||
try { return [Runtime.InteropServices.Marshal]::PtrToStringUni($ptr) }
|
try { return [Runtime.InteropServices.Marshal]::PtrToStringUni($ptr) }
|
||||||
finally {
|
finally {
|
||||||
if ($ptr -ne [IntPtr]::Zero) { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) }
|
if ($ptr -ne [IntPtr]::Zero) { [Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr) }
|
||||||
@@ -67,6 +64,7 @@ $FtpPassword = Read-PlainOrPrompt $FtpPassword "FTP password" $true
|
|||||||
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" $true
|
$WinRmCredentialPass = Read-PlainOrPrompt $WinRmCredentialPass "WinRM password" $true
|
||||||
|
|
||||||
Write-Host "1) Publishing..." -ForegroundColor Cyan
|
Write-Host "1) Publishing..." -ForegroundColor Cyan
|
||||||
|
if (Test-Path $PublishDir) { Remove-Item $PublishDir -Recurse -Force -ErrorAction SilentlyContinue }
|
||||||
New-Item -ItemType Directory -Force -Path $PublishDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $PublishDir | Out-Null
|
||||||
$publishArgs = @("publish", $ProjectPath, "-c", $Configuration, "-r", $Runtime, "-o", $PublishDir)
|
$publishArgs = @("publish", $ProjectPath, "-c", $Configuration, "-r", $Runtime, "-o", $PublishDir)
|
||||||
if (-not $SelfContained) { $publishArgs += "--self-contained=false" }
|
if (-not $SelfContained) { $publishArgs += "--self-contained=false" }
|
||||||
@@ -88,11 +86,11 @@ if ($RecycleAppPool) {
|
|||||||
try {
|
try {
|
||||||
Invoke-Command @invokeParams
|
Invoke-Command @invokeParams
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "WinRM stop failed: $($_.Exception.Message)`nIf not on domain/Kerberos, enable HTTPS WinRM or add TrustedHosts (winrm set winrm/config/client '@{TrustedHosts=\"\"\"$WinRmComputer\"\"\"}'), or set `$RecycleAppPool = $false`."
|
Write-Warning "WinRM stop failed: $($_.Exception.Message)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Host "2) Syncing via WinSCP (FTP mirror with delete)..." -ForegroundColor Cyan
|
Write-Host "3) Syncing via WinSCP (FTP mirror with delete)..." -ForegroundColor Cyan
|
||||||
$tempScript = New-TemporaryFile
|
$tempScript = New-TemporaryFile
|
||||||
@"
|
@"
|
||||||
option batch continue
|
option batch continue
|
||||||
@@ -123,7 +121,7 @@ if ($RecycleAppPool) {
|
|||||||
try {
|
try {
|
||||||
Invoke-Command @invokeParams
|
Invoke-Command @invokeParams
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "WinRM start failed: $($_.Exception.Message)`nIf not on domain/Kerberos, enable HTTPS WinRM or add TrustedHosts, or set `$RecycleAppPool = $false`."
|
Write-Warning "WinRM start failed: $($_.Exception.Message)."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user