58 lines
2.4 KiB
PowerShell
58 lines
2.4 KiB
PowerShell
# Publiceert kniip als zelfstandige single-file exe (geen .NET-installatie nodig op de doel-pc)
|
|
# en bouwt de installer als Inno Setup 6 aanwezig is.
|
|
# ScreenRecorderLib (screencasts) is een C++/CLI-assembly die niet uit de bundel geladen kan worden;
|
|
# IncludeAllContentForSelfExtract pakt daarom bij de eerste start alles uit naar %TEMP%\.net.
|
|
#
|
|
# .\build.ps1 -> artifacts\publish\Kniip.exe (+ installer indien mogelijk)
|
|
# .\build.ps1 -Version 1.2.0
|
|
|
|
param(
|
|
[string]$Version = "1.1.2",
|
|
[string]$Runtime = "win-x64"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = $PSScriptRoot
|
|
$publishDir = Join-Path $root "artifacts\publish"
|
|
|
|
# Gebruik een SDK in het gebruikersprofiel als er geen systeembrede SDK is.
|
|
$localDotnet = Join-Path $env:LOCALAPPDATA "Microsoft\dotnet"
|
|
if (-not (dotnet --list-sdks 2>$null) -and (Test-Path (Join-Path $localDotnet "dotnet.exe"))) {
|
|
$env:DOTNET_ROOT = $localDotnet
|
|
$env:PATH = "$localDotnet;$env:PATH"
|
|
}
|
|
|
|
if (Test-Path $publishDir) { Remove-Item $publishDir -Recurse -Force }
|
|
|
|
dotnet publish (Join-Path $root "src\Kniip\Kniip.csproj") `
|
|
-c Release -r $Runtime --self-contained true `
|
|
-p:PublishSingleFile=true `
|
|
-p:IncludeNativeLibrariesForSelfExtract=true `
|
|
-p:IncludeAllContentForSelfExtract=true `
|
|
-p:EnableCompressionInSingleFile=true `
|
|
-p:DebugType=none `
|
|
-p:Version=$Version `
|
|
-o $publishDir
|
|
if ($LASTEXITCODE -ne 0) { throw "dotnet publish is mislukt." }
|
|
|
|
Write-Host "Gepubliceerd: $publishDir\Kniip.exe" -ForegroundColor Green
|
|
|
|
# Losse exe met versienummer; de installer blijft Kniip.exe uit de publish-map gebruiken.
|
|
$portableExe = Join-Path $root "artifacts\Kniip-$Version.exe"
|
|
Copy-Item (Join-Path $publishDir "Kniip.exe") $portableExe -Force
|
|
Write-Host "Losse exe: $portableExe" -ForegroundColor Green
|
|
|
|
$iscc = @(
|
|
"${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe",
|
|
"$env:ProgramFiles\Inno Setup 6\ISCC.exe",
|
|
"$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe"
|
|
) | Where-Object { Test-Path $_ } | Select-Object -First 1
|
|
|
|
if ($iscc) {
|
|
& $iscc "/DAppVersion=$Version" "/DPublishDir=$publishDir" (Join-Path $root "installer\Kniip.iss")
|
|
if ($LASTEXITCODE -ne 0) { throw "Installer bouwen is mislukt." }
|
|
Write-Host "Installer: $root\artifacts\Kniip-Setup-$Version.exe" -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Inno Setup 6 niet gevonden; installer overgeslagen (winget install JRSoftware.InnoSetup)." -ForegroundColor Yellow
|
|
}
|