deploy: 修正FTP上传目标为/wwwroot并增强上传健壮性
- RemoteRoot 固定为 /wwwroot (IIS 站点物理根), 网页必须存放于 wwwroot 才可访问 - ftp_upload.ps1: 每文件独立连接、上传后校验大小、3次重试、日志记录 - 新增 ftp_fast.ps1 (快速覆盖上传) 与 ftp_sync.ps1 (仅补传缺失/大小不符文件) - 上传前删除服务商默认欢迎页 default.html, 避免优先于 index.html
This commit is contained in:
+12
-1
@@ -4,6 +4,9 @@
|
||||
# 2. npm run build 前端 (Vite, dist)
|
||||
# 3. FTP 上传合并产物至 IIS 站点根目录
|
||||
#
|
||||
# 重要: 官方提示 —— 网页必需存放在 wwwroot 目录下才能被访问!
|
||||
# 因此 RemoteRoot 固定为 /wwwroot (FTP 上的目录, 即 IIS 站点物理根)
|
||||
#
|
||||
# 用法:
|
||||
# powershell -ExecutionPolicy Bypass -File deploy/publish.ps1
|
||||
#
|
||||
@@ -14,7 +17,7 @@ param(
|
||||
[int] $FtpPort = 21,
|
||||
[string]$FtpUser = "wenchuanyi",
|
||||
[string]$FtpPass = "r7P^f*v7rFts",
|
||||
[string]$RemoteRoot = "/", # FTP 远端目标目录 (IIS 站点根目录)
|
||||
[string]$RemoteRoot = "/wwwroot", # FTP 远端目标目录 = IIS 站点根目录 (勿改!)
|
||||
[switch]$SkipBuild # 跳过构建, 仅上传已有产物
|
||||
)
|
||||
|
||||
@@ -106,6 +109,14 @@ function Send-FtpDirectory([string]$localDir, [string]$remoteDir) {
|
||||
}
|
||||
|
||||
# ---------------- 上传 ----------------
|
||||
# 删除服务商默认欢迎页 default.html, 避免 IIS 默认文档优先于 index.html
|
||||
function Remove-FtpFile([string]$remotePath) {
|
||||
$req = New-FtpRequest $remotePath ([System.Net.WebRequestMethods+Ftp]::DeleteFile)
|
||||
try { $null = $req.GetResponse(); Write-Host " DEL $remotePath" -ForegroundColor DarkGray }
|
||||
catch { }
|
||||
}
|
||||
Remove-FtpFile "$RemoteRoot/default.html"
|
||||
|
||||
New-FtpDirectory $RemoteRoot
|
||||
Send-FtpDirectory $StagingDir $RemoteRoot
|
||||
|
||||
|
||||
Reference in New Issue
Block a user