Files
rgb-led-strip-controller/scripts/release/package-velopack.ps1
T
fristy a7413c4b0e
CI / release (push) Successful in 13m54s
CI / build-and-test (push) Successful in 5m24s
ci: invoke vpk.dll directly, slim restore step
2026-09-05 16:23:07 +03:00

120 lines
4.7 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<#
.SYNOPSIS
Velopack ile Setup.exe üretimi. Self-contained publish alıp vpk pack yapar.
.DESCRIPTION
1. Proje dosyasından sürüm okur
2. dotnet publish (self-contained, single-file, win-x64)
3. vpk pack ile Setup.exe, Portable.zip ve feed dosyalarını üretir
4. Setup.exe ve Portable.zip'i istenen formata rename eder (feed dosyaları orijinal Velopack naming'de kalır)
5. Çıktı: artifacts/velopack/win-x64-stable/
.NOTES
Velopack CLI: NuGet paketinden dogrudan calistirilan vpk.dll kullanilir
Icon: Assets/AppIcon.ico (installer ikonu)
Velopack CLI args: camelCase (--outputDir, --packId, --packTitle, --packAuthors, --packVersion, --packDir, --mainExe)
#>
param(
[switch]$WhatIf
)
$ErrorActionPreference = "Stop"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
$repoRoot = Split-Path -Parent (Split-Path -Parent $scriptDir)
$projPath = Join-Path $repoRoot "src\RgbLedStripController\RgbLedStripController.csproj"
$iconPath = Join-Path $repoRoot "src\RgbLedStripController\Assets\AppIcon.ico"
$publishDir = Join-Path $repoRoot "artifacts\publish\win-x64"
$velopackDir = Join-Path $repoRoot "artifacts\velopack\win-x64-stable"
# Sürümü csproj'dan oku (birden fazla PropertyGroup olabilir)
$projXml = [xml](Get-Content $projPath)
$version = $projXml.Project.PropertyGroup | Where-Object { $_.Version } | Select-Object -First 1 -ExpandProperty Version
if (-not $version) { throw "Version not found in csproj" }
Write-Host "Version: $version" -ForegroundColor Cyan
# Publish output klasörü
$stagedPublishDir = Join-Path $publishDir $version
if (-not $WhatIf) {
if (Test-Path $stagedPublishDir) { Remove-Item -Recurse -Force $stagedPublishDir }
} else {
Write-Host "[WhatIf] Would clean: $stagedPublishDir"
}
# Velopack output klasörünü temizle (duplicate önleme)
if (-not $WhatIf) {
if (Test-Path $velopackDir) { Remove-Item -Recurse -Force $velopackDir }
New-Item -ItemType Directory -Force -Path $velopackDir | Out-Null
} else {
Write-Host "[WhatIf] Would clean and recreate: $velopackDir"
}
# 1. dotnet publish
$publishArgs = @(
"publish", $projPath
"-c", "Release"
"-r", "win-x64"
"--self-contained", "true"
"-p:PublishSingleFile=true"
"-p:PublishTrimmed=false"
"-p:IncludeNativeLibrariesForSelfExtract=true"
"-p:DebugType=none"
"-p:DebugSymbols=false"
"--configfile", (Join-Path $repoRoot "NuGet.Config")
"-o", $stagedPublishDir
)
Write-Host "dotnet publish..." -ForegroundColor Cyan
if (-not $WhatIf) {
& dotnet $publishArgs
if ($LASTEXITCODE -ne 0) { throw "dotnet publish failed ($LASTEXITCODE)" }
} else {
Write-Host "[WhatIf] dotnet $publishArgs"
}
# 2. vpk pack (args camelCase)
$nugetPkgs = $env:NUGET_PACKAGES
if (-not $nugetPkgs) { $nugetPkgs = Join-Path $env:USERPROFILE ".nuget/packages" }
$vpkDll = Join-Path $nugetPkgs "vpk/0.0.1298/tools/net8.0/any/vpk.dll"
if (-not (Test-Path $vpkDll)) { throw "vpk.dll not found at $vpkDll" }
$vpkArgs = @(
"pack",
"--outputDir", $velopackDir,
"--packId", "Fristy.RgbLedStripController",
"--packTitle", "RGB Led Strip Controller",
"--packAuthors", "fristy",
"--packVersion", $version,
"--icon", $iconPath,
"--packDir", $stagedPublishDir,
"--mainExe", "RgbLedStripController.exe"
)
Write-Host "vpk pack..." -ForegroundColor Cyan
if (-not $WhatIf) {
& dotnet $vpkDll $vpkArgs
if ($LASTEXITCODE -ne 0) { throw "vpk pack failed ($LASTEXITCODE)" }
} else {
Write-Host "[WhatIf] dotnet $vpkDll $vpkArgs"
}
# 3. Sadece Setup.exe ve Portable.zip'i istenen formata rename et
# Feed dosyaları (releases.*.json, *.nupkg) orijinal Velopack naming'de kalsın (auto-update için)
$setupSrc = Join-Path $velopackDir "Fristy.RgbLedStripController-win-Setup.exe"
$setupDst = Join-Path $velopackDir "RGBLedStripController-Setup-v${version}-x64.exe"
$portableSrc = Join-Path $velopackDir "Fristy.RgbLedStripController-win-Portable.zip"
$portableDst = Join-Path $velopackDir "RGBLedStripController-Portable-v${version}-x64.zip"
if (-not $WhatIf) {
if (Test-Path $setupSrc) { Move-Item -Force $setupSrc $setupDst; Write-Host "Renamed: $($setupDst)" }
if (Test-Path $portableSrc) { Move-Item -Force $portableSrc $portableDst; Write-Host "Renamed: $($portableDst)" }
} else {
Write-Host "[WhatIf] Would rename: $setupSrc -> $setupDst"
Write-Host "[WhatIf] Would rename: $portableSrc -> $portableDst"
}
Write-Host "Done. Output: $velopackDir" -ForegroundColor Green
if (-not $WhatIf) {
if (Test-Path $velopackDir) {
Get-ChildItem $velopackDir | ForEach-Object { Write-Host " $($_.Name) - $([math]::Round($_.Length/1MB,2)) MB" }
} else {
Write-Host "Warning: $velopackDir not found" -ForegroundColor Yellow
}
}