param( [string]$Output = "dist" ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $MyInvocation.MyCommand.Path python -c "import PyInstaller" 2>$null if ($LASTEXITCODE -ne 0) { throw "未找到 PyInstaller。先执行: python -m pip install pyinstaller pyserial" } $outDir = Join-Path $root $Output New-Item -ItemType Directory -Force -Path $outDir | Out-Null python -m PyInstaller --noconfirm --clean --onefile --windowed ` --name EG800FactoryHost ` --distpath $outDir ` --workpath (Join-Path $root ".pyinstaller-work") ` --specpath (Join-Path $root ".pyinstaller-spec") ` (Join-Path $root "factory_host.py") Copy-Item (Join-Path $root "factory_host_config.json") $outDir -Force Write-Host "输出: $(Join-Path $outDir 'EG800FactoryHost.exe')"