Files

26 lines
1.4 KiB
PowerShell

$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path $PSScriptRoot -Parent
$output = Join-Path $projectRoot 'bin/flutter-win-x64'
Push-Location (Join-Path $projectRoot 'flutter_manager')
try {
flutter build windows --release -t lib/main.dart
if ($LASTEXITCODE -ne 0) { throw 'Flutter publish failed' }
} finally { Pop-Location }
if (Test-Path -LiteralPath $output) {
if (Get-ChildItem -LiteralPath $output -Recurse -File -Filter '*.env') { throw 'Private env file in release directory; refusing to replace it' }
Remove-Item -LiteralPath $output -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $output | Out-Null
Copy-Item -Path (Join-Path $projectRoot 'flutter_manager/build/windows/x64/runner/Release/*') -Destination $output -Recurse -Force
foreach ($name in @('ads-client','ads-agent','adsctl','ads-usb')) {
$tool = Join-Path $projectRoot "bin/$name.exe"
if (-not (Test-Path -LiteralPath $tool)) { throw "先运行 scripts/build.ps1:缺少 $name" }
Copy-Item -LiteralPath $tool -Destination $output -Force
}
$tools = Join-Path $output 'tools/scrcpy'
New-Item -ItemType Directory -Force -Path $tools | Out-Null
Copy-Item -Path (Join-Path $projectRoot 'bin/tools/scrcpy/*') -Destination $tools -Recurse -Force
& (Join-Path $PSScriptRoot 'copy-windows-usb-driver.ps1') -Destination $output
# Private credentials are deliberately excluded from distributable artifacts.
Write-Host "Flutter published to $output (credentials excluded)"