# DMS 一键构建并运行脚本 # 用法:在项目根目录执行 .\build\run.ps1 # 参数与 build.ps1 一致并透传(如 -SkipFrontend 跳过前端构建) [CmdletBinding()] param( [switch]$SkipFrontend, [switch]$SkipPyInstallerInstall ) $ErrorActionPreference = "Stop" $ProjectRoot = Split-Path $PSScriptRoot -Parent $ReleaseDir = Join-Path $ProjectRoot "dist-package\dms-server" $ServerExe = Join-Path $ReleaseDir "dms-server.exe" Write-Host "========== DMS 一键构建并运行 ==========" -ForegroundColor Cyan Write-Host "项目根目录: $ProjectRoot" # ---------- 1. 执行构建 ---------- Write-Host "`n[1/2] 执行 build.ps1..." -ForegroundColor Yellow & (Join-Path $PSScriptRoot "build.ps1") @PSBoundParameters if (-not $?) { throw "build.ps1 执行失败" } # ---------- 2. 启动服务 ---------- if (-not (Test-Path $ServerExe)) { throw "未找到服务程序: $ServerExe" } Write-Host "`n[2/2] 启动 dms-server..." -ForegroundColor Yellow Write-Host "工作目录: $ReleaseDir" -ForegroundColor DarkGray Write-Host "浏览器访问: http://localhost:9345(Ctrl+C 停止服务)" -ForegroundColor DarkGray # exe 依赖工作目录定位 .env 与 dms-storage,需先进入发行目录再启动 Push-Location $ReleaseDir try { & ".\dms-server.exe" } finally { Pop-Location }