Files
HandyControl/build/pack-handycontrol.ps1
T
chfei b96b910bfc
Build / build (push) Canceled after 0s
升级 3.6.2.1
增加basic.xml
2026-10-27 12:01:19 +08:00

30 lines
1.4 KiB
PowerShell

param(
[string]$OutputPath = (Join-Path $PSScriptRoot '../artifacts/nuget')
)
$ErrorActionPreference = 'Stop'
$projectPath = Join-Path $PSScriptRoot '../src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj'
$project = [xml](Get-Content -LiteralPath $projectPath -Raw)
$version = $project.Project.PropertyGroup.Version | Where-Object { $_ } | Select-Object -First 1
$frameworks = ($project.Project.PropertyGroup.TargetFrameworks | Where-Object { $_ } | Select-Object -First 1).Split(';')
# Pack the outer multi-target project; passing TargetFramework would produce an incomplete package.
dotnet pack $projectPath --configuration Release --output $OutputPath --nologo
if ($LASTEXITCODE -ne 0) { throw 'HandyControl packing failed.' }
Add-Type -AssemblyName System.IO.Compression.FileSystem
$packagePath = Join-Path $OutputPath "HandyControl.$version.nupkg"
$archive = [System.IO.Compression.ZipFile]::OpenRead((Resolve-Path -LiteralPath $packagePath).Path)
try {
$entries = @($archive.Entries.FullName)
foreach ($framework in $frameworks) {
$packageFramework = if ($framework -match '^net\d+\.\d+-windows$') { "$framework`7.0" } else { $framework }
if ("lib/$packageFramework/HandyControl.dll" -notin $entries) {
throw "Package is missing the assembly for $framework."
}
}
} finally {
$archive.Dispose()
}
Write-Host "Verified package: $packagePath"