# Apply: new appsettings.json (localhost) + restore web.config (stdout off, triggers restart) + nested assets $ErrorActionPreference = "Continue" $FtpHost="116.198.221.125"; $FtpPort=21; $FtpUser="wenchuanyi"; $FtpPass="r7P^f*v7rFts" $Local = "D:\CodeBuddy\Pros\WenChuanyi\backend\WenChuanyi.Api\bin\Release\net8.0\publish" $Dist = "D:\CodeBuddy\Pros\WenChuanyi\frontend\dist" function NewR($p,$m,$to=90000){ $u="ftp://${FtpHost}:${FtpPort}/"+$p.TrimStart('/'); $r=[System.Net.FtpWebRequest]::Create($u); $r.Method=$m; $r.Credentials=New-Object System.Net.NetworkCredential($FtpUser,$FtpPass); $r.UsePassive=$true; $r.UseBinary=$true; $r.KeepAlive=$false; $r.Timeout=$to; $r } function Mk($p){ try{ $r=NewR $p ([System.Net.WebRequestMethods+Ftp]::MakeDirectory); $resp=$r.GetResponse(); try{$resp.Close()}catch{} }catch{} Start-Sleep -Milliseconds 300 } function GetSizeF($p){ try{ $r=NewR $p ([System.Net.WebRequestMethods+Ftp]::GetFileSize) 30000; $resp=$r.GetResponse(); $s=$resp.ContentLength; $resp.Close(); return $s } catch{ return -1 } } function UpF($lp,$rp){ $want=(Get-Item $lp).Length for($i=1;$i -le 4;$i++){ try{ $r=NewR $rp ([System.Net.WebRequestMethods+Ftp]::UploadFile) 300000 $b=[IO.File]::ReadAllBytes($lp); $r.ContentLength=$b.Length $s=$r.GetRequestStream(); try{ $s.Write($b,0,$b.Length) } finally { $s.Close() } $resp=$r.GetResponse(); try{ $resp.Close() }catch{} Start-Sleep -Milliseconds 300 $after=GetSizeF $rp if($after -eq $want){ Write-Host "UP OK $rp"; return $true } Write-Host "SIZE MISMATCH $rp got=$after want=$want" }catch{ Write-Host "RETRY($i) $rp : $($_.Exception.Message)" } Start-Sleep -Seconds 3 } Write-Host "FAIL $rp"; return $false } # 1. appsettings.json (localhost db) UpF "$Local\appsettings.json" "/wwwroot/appsettings.json" # 2. web.config: stdout off (production) - also triggers app pool restart $wc = @" "@ $tmp = Join-Path $env:TEMP "wcy_web_prod.config" [IO.File]::WriteAllText($tmp, $wc, [Text.Encoding]::UTF8) UpF $tmp "/wwwroot/web.config" # 3. nested wwwroot assets (frontend static files served by ASP.NET Core WebRoot) Mk "/wwwroot/wwwroot/assets" UpF "$Dist\assets\index-Bwz67ZeI.js" "/wwwroot/wwwroot/assets/index-Bwz67ZeI.js" UpF "$Dist\assets\index-c9wa7v4K.css" "/wwwroot/wwwroot/assets/index-c9wa7v4K.css" Write-Host "APPLY DONE"