Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
54 lines (45 loc) · 2.54 KB
/
Copy pathbuild.ps1
File metadata and controls
54 lines (45 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<#
.SYNOPSIS
Build single-file exes with version in filename.
-> out\NewMenuManager_v1.00.1_GUI.exe
-> out\nmcli_v1.00.1_CLI.exe
#>
param([string]$Version = "1.00.1")
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSCommandPath
$out = Join-Path $root "out"
Write-Host "============================================" -ForegroundColor Cyan
Write-Host " NewMenuManager - Build v$Version" -ForegroundColor Cyan
Write-Host "============================================" -ForegroundColor Cyan
Write-Host ""
if (Test-Path $out) { Remove-Item $out -Recurse -Force }
Write-Host "[1/3] Restore packages..." -ForegroundColor Cyan
dotnet restore "$root\NewMenuManager.sln" 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) { Write-Host "FAILED" -ForegroundColor Red; pause; exit 1 }
Write-Host " OK" -ForegroundColor Green
Write-Host "[2/3] Build GUI (NewMenuManager_v${Version}_GUI.exe)..." -ForegroundColor Cyan
dotnet publish "$root\NewMenuManager.GUI" -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -o $out 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) { Write-Host "FAILED" -ForegroundColor Red; pause; exit 1 }
$f = Get-ChildItem "$out\NewMenuManager.exe" -ErrorAction SilentlyContinue
if ($f) { Rename-Item $f.FullName "NewMenuManager_v${Version}_GUI.exe" -Force }
Write-Host " -> NewMenuManager_v${Version}_GUI.exe" -ForegroundColor Green
Write-Host "[3/3] Build CLI (nmcli_v${Version}_CLI.exe)..." -ForegroundColor Cyan
dotnet publish "$root\NewMenuManager.CLI" -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true -p:EnableCompressionInSingleFile=true -o $out 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) { Write-Host "FAILED" -ForegroundColor Red; pause; exit 1 }
$f = Get-ChildItem "$out\nmcli.exe" -ErrorAction SilentlyContinue
if ($f) { Rename-Item $f.FullName "nmcli_v${Version}_CLI.exe" -Force }
Write-Host " -> nmcli_v${Version}_CLI.exe" -ForegroundColor Green
# Clean junk, keep only exes
Get-ChildItem $out -Exclude "*.exe" | Remove-Item -Force -Recurse
Copy-Item "$root\NewMenuManager.GUI\logo.ico" $out -Force -ErrorAction SilentlyContinue
Write-Host ""
Write-Host "============================================" -ForegroundColor Green
Write-Host " Build Complete - v$Version" -ForegroundColor Green
Write-Host "============================================" -ForegroundColor Green
Write-Host ""
Get-ChildItem $out -Filter "*.exe" | ForEach-Object {
$sz = [math]::Round($_.Length / 1MB, 1)
Write-Host " $($_.Name) ($sz MB)" -ForegroundColor White
}
Write-Host ""
pause