调试环境正常,发布时统一发布前后台
This commit is contained in:
+36
@@ -0,0 +1,36 @@
|
||||
# 1. Path Configuration
|
||||
$rootPath = Get-Location
|
||||
$vuePath = Join-Path $rootPath "web-app"
|
||||
$wpfPath = Join-Path $rootPath "WebView2Demo"
|
||||
$publishPath = Join-Path $rootPath "Publish"
|
||||
|
||||
# 2. Cleanup old publish folder
|
||||
Write-Host ">>> Cleaning old publish files..." -ForegroundColor Cyan
|
||||
if (Test-Path $publishPath) { Remove-Item -Path $publishPath -Recurse -Force }
|
||||
New-Item -ItemType Directory -Path $publishPath | Out-Null
|
||||
|
||||
# 3. Build Vue Frontend
|
||||
Write-Host ">>> Building Vue Frontend..." -ForegroundColor Cyan
|
||||
Set-Location $vuePath
|
||||
npm run build
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "Vue build failed!" -ForegroundColor Red; exit }
|
||||
|
||||
# 4. Copy Vue assets to WPF directory
|
||||
Write-Host ">>> Syncing frontend assets to WPF project..." -ForegroundColor Cyan
|
||||
$vueDist = Join-Path $vuePath "dist"
|
||||
$wpfWwwroot = Join-Path $wpfPath "wwwroot"
|
||||
|
||||
if (Test-Path $wpfWwwroot) { Remove-Item -Path $wpfWwwroot -Recurse -Force }
|
||||
New-Item -ItemType Directory -Path $wpfWwwroot | Out-Null
|
||||
Copy-Item -Path "$vueDist\*" -Destination $wpfWwwroot -Recurse -Force
|
||||
|
||||
# 5. Build and Publish WPF Backend
|
||||
Write-Host ">>> Publishing WPF project..." -ForegroundColor Cyan
|
||||
Set-Location $wpfPath
|
||||
dotnet publish -c Release -o $publishPath
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host "WPF publish failed!" -ForegroundColor Red; exit }
|
||||
|
||||
Write-Host "`n>>> Publish complete! Output directory: $publishPath" -ForegroundColor Green
|
||||
Write-Host ">>> You can run $publishPath\WebView2Demo.exe to start the application." -ForegroundColor Green
|
||||
|
||||
Set-Location $rootPath
|
||||
Reference in New Issue
Block a user