Reduce Windows DLL dependencies and package release 0.2.1

This commit is contained in:
tongtong committed 2026-11-13 12:24:24 +08:00
1 parent fc0edd433f
commit efaf16de18
17 files changed
+153 -21

No files matched your search

+13 -2
View File
@@ -1,16 +1,27 @@
param(
[string]$Runtime = 'win-x64',
[ValidateSet('win-x64','win-arm64','linux-x64','linux-arm64','osx-x64','osx-arm64')][string]$Runtime = 'win-x64',
[switch]$FrameworkDependent
)
$ErrorActionPreference = 'Stop'
$projectRoot = Split-Path $PSScriptRoot -Parent
$outputDirectory = Join-Path $projectRoot "bin/desktop-$Runtime"
$selfContained = if ($FrameworkDependent) { 'false' } else { 'true' }
# Publish to a fresh staging folder so obsolete runtime DLLs cannot survive upgrades.
$stage = Join-Path $projectRoot ('bin/publish-desktop-' + [guid]::NewGuid().ToString('N'))
$publishOptions=@()
if ($Runtime.StartsWith('win-') -and -not $FrameworkDependent) {
$publishOptions=@('-p:PublishSingleFile=true','-p:IncludeNativeLibrariesForSelfExtract=false','-p:EnableCompressionInSingleFile=true','-p:DebugType=embedded')
}
Push-Location (Join-Path $projectRoot 'desktop')
try {
dotnet publish Ads.Desktop -c Release -r $Runtime --self-contained $selfContained -o $outputDirectory --nologo
dotnet publish Ads.Desktop -c Release -r $Runtime --self-contained $selfContained -o $stage --nologo @publishOptions
if ($LASTEXITCODE -ne 0) { throw 'Desktop publish failed' }
} finally { Pop-Location }
if (Test-Path -LiteralPath $outputDirectory) {
if (Get-ChildItem -LiteralPath $outputDirectory -Recurse -File -Filter '*.env') { throw 'Private env file in release directory; refusing to replace it' }
Remove-Item -LiteralPath $outputDirectory -Recurse -Force
}
Move-Item -LiteralPath $stage -Destination $outputDirectory
$suffix = if ($Runtime.StartsWith('win-')) { '.exe' } else { '' }
foreach ($toolName in @('ads-client', 'ads-usb', 'adsctl', 'ads-agent')) {
$client = Join-Path $projectRoot ('bin/' + $toolName + $suffix)