Files
qhmes/yy-admin-master/installer/build-installer.ps1

90 lines
2.7 KiB
PowerShell

# Release publish + WebView2 bootstrap download + Inno Setup ISCC
# Requires Inno Setup 6 (ISCC.exe)
$ErrorActionPreference = 'Stop'
$Root = Split-Path -Parent $PSScriptRoot
$Csproj = Join-Path $Root 'YY.Admin\YY.Admin.csproj'
$PublishRel = 'YY.Admin\bin\Release\net8.0-windows10.0.19041\win-x64\publish'
$PublishDir = Join-Path $Root $PublishRel
$RedistDir = Join-Path $PSScriptRoot 'redist'
$WebView2Exe = Join-Path $RedistDir 'MicrosoftEdgeWebview2Setup.exe'
$WebView2Url = 'https://go.microsoft.com/fwlink/p/?LinkId=2124703'
Write-Host '>>> dotnet publish (Release, win-x64)...'
dotnet publish $Csproj -c Release `
-p:IncludeNativeLibrariesForSelfExtract=true `
-p:EnableCompressionInSingleFile=true `
--verbosity minimal
if (-not (Test-Path $PublishDir)) {
throw "Publish output not found: $PublishDir"
}
$cfgPublish = Join-Path $PublishDir 'Configuration\appsettings.json'
if (-not (Test-Path $cfgPublish)) {
throw "Missing Configuration\appsettings.json under publish (ExcludeFromSingleFile required). Path: $cfgPublish"
}
New-Item -ItemType Directory -Force -Path $RedistDir | Out-Null
if (-not (Test-Path $WebView2Exe)) {
Write-Host '>>> Downloading WebView2 Evergreen bootstrapper...'
Invoke-WebRequest -Uri $WebView2Url -OutFile $WebView2Exe -UseBasicParsing
}
function Find-InnoCompiler {
if ($env:ISCC -and (Test-Path -LiteralPath $env:ISCC)) {
return $env:ISCC
}
if ($env:INNO_SETUP_DIR) {
$p = Join-Path $env:INNO_SETUP_DIR.TrimEnd('\') 'ISCC.exe'
if (Test-Path -LiteralPath $p) {
return $p
}
}
$cmd = Get-Command 'iscc.exe' -ErrorAction SilentlyContinue
if ($cmd -and $cmd.Source -and (Test-Path -LiteralPath $cmd.Source)) {
return $cmd.Source
}
$candidates = @(
'D:\Inno Setup 6\ISCC.exe'
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe"
"${env:ProgramFiles}\Inno Setup 6\ISCC.exe"
"${env:LocalAppData}\Programs\Inno Setup 6\ISCC.exe"
)
foreach ($c in $candidates) {
if ($c -and (Test-Path -LiteralPath $c)) {
return $c
}
}
return $null
}
$iscc = Find-InnoCompiler
if (-not $iscc) {
throw @'
ISCC.exe not found.
1) Install Inno Setup 6: https://jrsoftware.org/isdl.php
2) Or set env ISCC to full path of ISCC.exe, e.g.:
set ISCC=C:\Program Files (x86)\Inno Setup 6\ISCC.exe
3) Or set INNO_SETUP_DIR to the Inno Setup 6 folder.
Then run this script again.
'@
}
Write-Host ">>> Using ISCC: $iscc"
$iss = Join-Path $PSScriptRoot 'YY.Admin.Setup.iss'
Write-Host '>>> Compiling installer (working dir: installer)...'
Push-Location $PSScriptRoot
try {
& $iscc "`"$iss`""
} finally {
Pop-Location
}
$outDir = Join-Path $Root '_installer_output'
Write-Host ">>> Done. Output folder: $outDir"