build: package Avalonia and Flutter Windows installers
This commit is contained in:
1 parent
82a84a0223
commit
9aa39d7a5a
5 files changed
+85
-2
No files matched your search
@@ -0,0 +1,42 @@
|
||||
param(
|
||||
[ValidateSet('All','Avalonia','Flutter')][string]$Edition='All',
|
||||
[string]$Compiler,
|
||||
[switch]$SkipBuild
|
||||
)
|
||||
$ErrorActionPreference='Stop'
|
||||
$root=Split-Path $PSScriptRoot -Parent
|
||||
if (-not $Compiler) {
|
||||
$candidates=@((Join-Path $root 'work/installer-tools/inno/ISCC.exe'),"${env:ProgramFiles(x86)}/Inno Setup 6/ISCC.exe", "$env:ProgramFiles/Inno Setup 7/ISCC.exe")
|
||||
$Compiler=$candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
|
||||
}
|
||||
if (-not $Compiler) { throw 'Install Inno Setup 6/7 or specify -Compiler path/to/ISCC.exe' }
|
||||
$version=[regex]::Match((Get-Content (Join-Path $root 'Cargo.toml') -Raw),'(?m)^version = "([0-9.]+)"').Groups[1].Value
|
||||
if (-not $version) { throw 'Workspace version missing' }
|
||||
$output=Join-Path $root 'bin/installers'
|
||||
New-Item -ItemType Directory -Force -Path $output | Out-Null
|
||||
foreach ($name in @('Avalonia','Flutter')) {
|
||||
if ($Edition -ne 'All' -and $Edition -ne $name) { continue }
|
||||
$folder=if ($name -eq 'Avalonia') { 'desktop-win-x64' } else { 'flutter-win-x64' }
|
||||
$exe=if ($name -eq 'Avalonia') { 'Ads.Desktop.exe' } else { 'ads_manager.exe' }
|
||||
if (-not $SkipBuild) {
|
||||
$build=if ($name -eq 'Avalonia') { 'build-desktop.ps1' } else { 'build-flutter.ps1' }
|
||||
& (Join-Path $PSScriptRoot $build)
|
||||
if ($LASTEXITCODE) { throw "$name build failed" }
|
||||
}
|
||||
$source=Join-Path $root "bin/$folder"
|
||||
if ($name -eq 'Flutter') {
|
||||
$crt=Get-ChildItem "$env:ProgramFiles/Microsoft Visual Studio/2022/*/VC/Redist/MSVC/*/x64/Microsoft.VC143.CRT" -Directory -ErrorAction SilentlyContinue | Sort-Object FullName -Descending | Select-Object -First 1
|
||||
if ($crt) { Copy-Item -Path (Join-Path $crt.FullName '*.dll') -Destination $source -Force }
|
||||
foreach ($runtime in @('msvcp140.dll','vcruntime140.dll','vcruntime140_1.dll')) {
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $source $runtime))) { throw "Missing redistributable C++ runtime: $runtime" }
|
||||
}
|
||||
}
|
||||
foreach ($file in @($exe,'adsctl.exe','ads-agent.exe','ads-client.exe','tools/scrcpy/adb.exe','tools/scrcpy/scrcpy.exe')) {
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $source $file))) { throw "Missing payload: $folder/$file" }
|
||||
}
|
||||
if (Get-ChildItem -LiteralPath $source -Recurse -File -Filter '*.env') { throw 'Credential file found in release payload; remove it before packaging' }
|
||||
& $Compiler "/DVersion=$version" "/DEdition=$name" "/DExecutable=$exe" "/DSource=$source" "/DOutput=$output" (Join-Path $root 'deploy/windows/desktop-installer.iss')
|
||||
if ($LASTEXITCODE) { throw "$name installer compilation failed" }
|
||||
$package=Join-Path $output "ADS-$name-$version-win-x64-Setup.exe"
|
||||
(Get-FileHash -LiteralPath $package -Algorithm SHA256).Hash.ToLowerInvariant()+' '+[IO.Path]::GetFileName($package) | Set-Content -LiteralPath ($package+'.sha256') -Encoding ascii
|
||||
}
|
||||
Reference in new issue
Block a user