-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPublish.ps1
More file actions
96 lines (78 loc) · 3.58 KB
/
Copy pathPublish.ps1
File metadata and controls
96 lines (78 loc) · 3.58 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
<#
.SYNOPSIS
Publishes MemoryWatchDog Launcher + WPF app for both x64 and x86 architectures.
.DESCRIPTION
Produces the following layout:
publish\MemoryWatchDog.Launcher.exe (AnyCPU launcher, user entry point)
publish\x64\MemoryWatchDog_x64.exe (x64 build)
publish\x86\MemoryWatchDog_x86.exe (x86 build)
The launcher detects the target process architecture and starts the correct build.
Run from solution root:
.\Publish.ps1
.\Publish.ps1 -Configuration Debug
.\Publish.ps1 -SelfContained
Or right-click -> Run with PowerShell from Windows Explorer.
#>
param(
[string]$Configuration = "Release",
[string]$OutputRoot = "publish",
[switch]$SelfContained
)
$ErrorActionPreference = "Stop"
$solutionDir = $PSScriptRoot
$wpfProject = Join-Path $solutionDir "MemoryWatchDog.Wpf\MemoryWatchDog.Wpf.csproj"
$launcherProject = Join-Path $solutionDir "MemoryWatchDog.Launcher\MemoryWatchDog.Launcher.csproj"
if ($SelfContained) { $selfContainedFlag = "true" } else { $selfContainedFlag = "false" }
$runtimes = @("win-x64", "win-x86")
Write-Host ""
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " MemoryWatchDog - Full Publish" -ForegroundColor Cyan
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " SolutionDir : $solutionDir"
Write-Host " Configuration : $Configuration"
Write-Host " Output : $OutputRoot"
Write-Host " SelfContained : $selfContainedFlag"
Write-Host ""
# 1. Publish the Launcher (AnyCPU)
$launcherOutput = Join-Path $solutionDir $OutputRoot
Write-Host "Publishing Launcher -> $launcherOutput ..." -ForegroundColor Yellow
dotnet publish $launcherProject --configuration $Configuration --output $launcherOutput /p:PublishSingleFile=false
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Launcher publish failed" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit $LASTEXITCODE
}
Write-Host " OK" -ForegroundColor Green
# 2. Publish WPF app for each architecture
foreach ($rid in $runtimes) {
$arch = $rid.Replace("win-", "")
$outputDir = Join-Path (Join-Path $solutionDir $OutputRoot) $arch
Write-Host "Publishing WPF $rid -> $outputDir ..." -ForegroundColor Yellow
dotnet publish $wpfProject --configuration $Configuration --runtime $rid --self-contained $selfContainedFlag --output $outputDir /p:PublishSingleFile=false /p:_IsPublishBothInner=true
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Publish failed for $rid" -ForegroundColor Red
Read-Host "Press Enter to exit"
exit $LASTEXITCODE
}
# Copy exe with architecture suffix for easy identification
$srcExe = Join-Path $outputDir "MemoryWatchDog.Wpf.exe"
$destExe = Join-Path $outputDir "MemoryWatchDog_$arch.exe"
if (Test-Path $srcExe) {
Copy-Item $srcExe $destExe -Force
}
Write-Host " OK" -ForegroundColor Green
}
Write-Host ""
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host " Publish complete!" -ForegroundColor Green
Write-Host ""
Write-Host " Layout:" -ForegroundColor White
Write-Host " $OutputRoot\MemoryWatchDog.Launcher.exe <- start this"
Write-Host " $OutputRoot\x64\MemoryWatchDog_x64.exe"
Write-Host " $OutputRoot\x86\MemoryWatchDog_x86.exe"
Write-Host ""
Write-Host " The launcher selects the correct build" -ForegroundColor White
Write-Host " based on the target process architecture." -ForegroundColor White
Write-Host "=============================================" -ForegroundColor Cyan
Write-Host ""
Read-Host "Press Enter to exit"