-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.ps1
More file actions
101 lines (90 loc) · 3.35 KB
/
Copy pathpublish.ps1
File metadata and controls
101 lines (90 loc) · 3.35 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# publish.ps1 - PMR CM portable single-file publish script
# Usage:
# .\publish.ps1 # Dry-run: shows what would be built
# .\publish.ps1 -DryRun:$false # Actually builds to .\dist\
#
# Output: dist\PMR CM.exe + dist\PMR CM.Helper.exe (self-contained, no runtime required)
# WARNING: Do NOT add PublishTrimmed=true. WPF uses reflection; trimming breaks bindings.
param(
[bool]$DryRun = $true
)
$ErrorActionPreference = "Stop"
$RepoRoot = $PSScriptRoot
$UIProject = Join-Path $RepoRoot "src\EWSR_PMR_ModApp.UI\EWSR_PMR_ModApp.UI.csproj"
$HelperProject = Join-Path $RepoRoot "src\EWSR_PMR_ModApp.Helper\EWSR_PMR_ModApp.Helper.csproj"
$DistDir = Join-Path $RepoRoot "dist"
# UI publish args (WPF -- no trimming)
$UIArgs = @(
"publish", $UIProject,
"-c", "Release",
"-r", "win-x64",
"--self-contained", "true",
"-p:PublishSingleFile=true",
"-p:IncludeNativeLibrariesForSelfExtract=true",
"-p:EnableCompressionInSingleFile=true",
"-p:ReadyToRun=true",
"-o", $DistDir
)
# Helper publish args (console exe -- no WPF, trimming also unsafe due to JSON reflection)
$HelperArgs = @(
"publish", $HelperProject,
"-c", "Release",
"-r", "win-x64",
"--self-contained", "true",
"-p:PublishSingleFile=true",
"-p:IncludeNativeLibrariesForSelfExtract=true",
"-p:EnableCompressionInSingleFile=true",
"-p:ReadyToRun=true",
"-o", $DistDir
)
Write-Host ""
Write-Host "PMR CM -- Publish Script" -ForegroundColor Cyan
Write-Host "========================" -ForegroundColor Cyan
Write-Host ""
Write-Host " Mode : $(if ($DryRun) { 'DRY RUN (no changes)' } else { 'LIVE -- will write to dist\' })"
Write-Host " UI project : $UIProject"
Write-Host " Helper : $HelperProject"
Write-Host " Target : win-x64, self-contained, single-file"
Write-Host " Output dir : $DistDir"
Write-Host ""
if ($DryRun) {
Write-Host "[DRY RUN] No files were written. Run with -DryRun:`$false to publish." -ForegroundColor Yellow
Write-Host ""
exit 0
}
# Clean the dist directory before publishing.
if (Test-Path $DistDir) {
Write-Host "Cleaning existing dist\ ..." -ForegroundColor Gray
Remove-Item -Recurse -Force $DistDir
}
Write-Host "Publishing PMR CM.exe ..." -ForegroundColor Green
& dotnet @UIArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "UI publish failed (exit code $LASTEXITCODE)."
exit $LASTEXITCODE
}
Write-Host ""
Write-Host "Publishing PMR CM.Helper.exe ..." -ForegroundColor Green
& dotnet @HelperArgs
if ($LASTEXITCODE -ne 0) {
Write-Error "Helper publish failed (exit code $LASTEXITCODE)."
exit $LASTEXITCODE
}
Write-Host ""
Write-Host "Publish succeeded. Output:" -ForegroundColor Green
Get-ChildItem $DistDir -File | Sort-Object Name | ForEach-Object {
$sizeMB = [math]::Round($_.Length / 1MB, 2)
Write-Host (" {0,-40} {1,8} MB" -f $_.Name, $sizeMB)
}
Write-Host ""
Write-Host "Single-file check (should be 2 exes, no loose DLLs):" -ForegroundColor Cyan
$exeCount = (Get-ChildItem $DistDir -Filter "*.exe").Count
$dllCount = (Get-ChildItem $DistDir -Filter "*.dll").Count
Write-Host " .exe files : $exeCount"
Write-Host " .dll files : $dllCount"
if ($dllCount -gt 0) {
Write-Warning "Loose DLLs found -- single-file bundling may not have worked as expected."
} else {
Write-Host " No loose DLLs -- clean single-file build." -ForegroundColor Green
}
Write-Host ""