45 lines
1.9 KiB
PowerShell
45 lines
1.9 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string] $Compiler,
|
|
|
|
[ValidateSet('win-x64', 'win-x86', 'win-arm64')]
|
|
[string[]] $Architecture = @('win-x64', 'win-x86', 'win-arm64')
|
|
)
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
$compilerPath = (Resolve-Path -LiteralPath $Compiler).ProviderPath
|
|
$dist = Join-Path $PSScriptRoot 'dist'
|
|
$setup = Join-Path $PSScriptRoot 'OfflineSetup.iss'
|
|
$staging = Join-Path $PSScriptRoot 'obj\offline-setup'
|
|
$supportedSystems = @{ 'win-x64' = 'x64os'; 'win-x86' = 'x86compatible'; 'win-arm64' = 'arm64' }
|
|
New-Item -ItemType Directory -Path $staging -Force | Out-Null
|
|
$staging = (Resolve-Path -LiteralPath $staging).ProviderPath
|
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
|
|
|
foreach ($runtime in $Architecture) {
|
|
$portable = "DailyFileSync-standalone-$runtime"
|
|
$archive = Join-Path $dist "$portable.zip"
|
|
if (-not (Test-Path -LiteralPath $archive -PathType Leaf)) {
|
|
throw "Missing $archive. Run build-standalone.ps1 first."
|
|
}
|
|
|
|
$workingDirectory = Join-Path $staging ([guid]::NewGuid().ToString('N'))
|
|
New-Item -ItemType Directory -Path $workingDirectory | Out-Null
|
|
try {
|
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $workingDirectory)
|
|
$payload = Join-Path $workingDirectory $portable
|
|
$package = "DailyFileSync-Offline-Setup-$runtime"
|
|
& $compilerPath /Qp "/DPayloadPath=$payload" "/DPackageArchitecture=$($supportedSystems[$runtime])" "/DPackageName=$package" "/O$dist" $setup
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Installer compilation failed for $runtime with exit code $LASTEXITCODE."
|
|
}
|
|
|
|
Write-Output (Join-Path $dist "$package.exe")
|
|
} finally {
|
|
$resolvedDirectory = (Resolve-Path -LiteralPath $workingDirectory).ProviderPath
|
|
if ((Split-Path -Parent $resolvedDirectory) -eq $staging) {
|
|
Remove-Item -LiteralPath $resolvedDirectory -Recurse -Force
|
|
}
|
|
}
|
|
}
|