-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish.ps1
More file actions
74 lines (65 loc) · 2.41 KB
/
Copy pathpublish.ps1
File metadata and controls
74 lines (65 loc) · 2.41 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
# Publish a self-contained single-file SysManager.exe for Windows x64.
#
# Usage:
# .\publish.ps1 # default: Release, win-x64, output ./publish
# .\publish.ps1 -Runtime win-arm64
# .\publish.ps1 -Output dist
[CmdletBinding()]
param(
[string]$Configuration = 'Release',
[string]$Runtime = 'win-x64',
[string]$Output = 'publish',
[string]$Version = '',
[switch]$NoTrim
)
$ErrorActionPreference = 'Stop'
$project = Join-Path $PSScriptRoot 'SysManager\SysManager\SysManager.csproj'
if (-not (Test-Path $project)) {
throw "Project not found: $project"
}
Write-Host "Publishing SysManager..." -ForegroundColor Cyan
Write-Host " Config : $Configuration"
Write-Host " Runtime: $Runtime"
Write-Host " Output : $Output"
$publishArgs = @(
'publish', $project,
'-c', $Configuration,
'-r', $Runtime,
'--self-contained', 'true',
'-p:PublishSingleFile=true',
'-p:IncludeNativeLibrariesForSelfExtract=true',
'-p:EnableCompressionInSingleFile=true',
'-p:DebugType=embedded',
# Reproducible, path-normalized release build. ContinuousIntegrationBuild
# turns on DeterministicSourcePaths, which (with SourceLink, already
# referenced in Directory.Build.props) rewrites the local source root in the
# embedded PDB to a '/_/' prefix — so the shipped single-file binary never
# carries an absolute build path. publish.ps1 produces release artifacts only
# (release.yml invokes it), so this is correctly scoped to release builds and
# does not affect local IDE/dev debugging.
'-p:ContinuousIntegrationBuild=true',
'-p:Deterministic=true',
'-o', $Output
)
# Inject version from tag so the assembly reports the correct release number.
if ($Version -ne '') {
Write-Host " Version: $Version"
$publishArgs += "-p:Version=$Version"
$publishArgs += "-p:FileVersion=$Version.0"
$publishArgs += "-p:AssemblyVersion=$Version.0"
}
# WPF doesn't support IL trimming reliably, so it's off by default.
if ($NoTrim) {
$publishArgs += '-p:PublishTrimmed=false'
}
& dotnet @publishArgs
if ($LASTEXITCODE -ne 0) {
throw "dotnet publish failed with exit code $LASTEXITCODE"
}
$exe = Join-Path $Output 'SysManager.exe'
if (Test-Path $exe) {
$size = (Get-Item $exe).Length / 1MB
Write-Host ("Done. {0} ({1:N1} MB)" -f $exe, $size) -ForegroundColor Green
} else {
Write-Warning "Expected $exe but it was not produced."
}