mirror of
https://github.com/AtomUI/AtomUI.git
synced 2026-10-17 05:31:01 +08:00
105 lines
4.2 KiB
PowerShell
105 lines
4.2 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[ValidateSet("Debug", "Release")]
|
|
[string]$BuildType = "Release",
|
|
[string]$PackageOutputDir = "",
|
|
[string]$PackageValidationBaselineVersion = ""
|
|
)
|
|
|
|
Set-StrictMode -Version Latest
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
. "$PSScriptRoot/NuGetPackageProjects.ps1"
|
|
|
|
if ([string]::IsNullOrWhiteSpace($PackageOutputDir)) {
|
|
$PackageOutputDir = Join-Path $repositoryRoot ".artifacts/Nuget/$BuildType"
|
|
}
|
|
$PackageOutputDir = [System.IO.Path]::GetFullPath($PackageOutputDir)
|
|
New-Item -Path $PackageOutputDir -ItemType Directory -Force | Out-Null
|
|
|
|
function Invoke-AtomUIDotNet {
|
|
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string[]]$Arguments
|
|
)
|
|
|
|
Write-Host "dotnet $($Arguments -join ' ')"
|
|
& dotnet @Arguments
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "dotnet $($Arguments[0]) failed with exit code $LASTEXITCODE"
|
|
}
|
|
}
|
|
|
|
$buildArguments = @(
|
|
"--configuration", $BuildType,
|
|
"--disable-build-servers",
|
|
"-m:1",
|
|
"/nr:false"
|
|
)
|
|
|
|
# When a baseline version is supplied, the packages are validated against that released version:
|
|
# ApiCompat compares the C# public API (build/PackageValidation.props) and verify-package-layout.ps1
|
|
# compares the consumer-visible package layout. The baseline packages are fetched by the build step
|
|
# below, whose implicit restore carries the validation property; packing then reuses that restore
|
|
# because it runs with --no-build. Do not add a separate `dotnet restore` here: a restore without
|
|
# the Release configuration would overwrite the assets file with the Debug target frameworks.
|
|
$validationArguments = @()
|
|
if (-not [string]::IsNullOrWhiteSpace($PackageValidationBaselineVersion)) {
|
|
$validationArguments = @("-p:AtomUIPackageValidationBaselineVersion=$PackageValidationBaselineVersion")
|
|
}
|
|
|
|
# Prerequisite tool projects are not published packages, so they must never be validated against a
|
|
# released baseline (build-only tool projects have no published package).
|
|
foreach ($project in $AtomUIReleaseBuildPrerequisiteProjects) {
|
|
Invoke-AtomUIDotNet -Arguments (@("build", $project) + $buildArguments)
|
|
}
|
|
|
|
foreach ($project in $AtomUIReleasePackageProjects) {
|
|
Invoke-AtomUIDotNet -Arguments (@("build", $project) + $buildArguments + $validationArguments)
|
|
}
|
|
|
|
foreach ($project in $AtomUIReleasePackageProjects) {
|
|
Invoke-AtomUIDotNet -Arguments (@(
|
|
"pack",
|
|
$project,
|
|
"--no-build",
|
|
"--output", $PackageOutputDir
|
|
) + $buildArguments + $validationArguments)
|
|
}
|
|
|
|
[xml]$versionProps = Get-Content -LiteralPath (Join-Path $repositoryRoot "build/Versions.props")
|
|
$version = [string]$versionProps.Project.PropertyGroup.AtomUIVersion
|
|
if ([string]::IsNullOrWhiteSpace($version)) {
|
|
throw "Unable to read AtomUIVersion from build/Versions.props"
|
|
}
|
|
|
|
$expectedPackageNames = @($AtomUIExpectedPackageIds | ForEach-Object { "$($_).$version.nupkg" })
|
|
$actualPackageNames = @(
|
|
Get-ChildItem -LiteralPath $PackageOutputDir -Filter "*.nupkg" -File |
|
|
Select-Object -ExpandProperty Name
|
|
)
|
|
$missingPackages = @($expectedPackageNames | Where-Object { $_ -notin $actualPackageNames })
|
|
$unexpectedPackages = @($actualPackageNames | Where-Object { $_ -notin $expectedPackageNames })
|
|
|
|
if ($missingPackages.Count -gt 0) {
|
|
throw "Missing NuGet packages: $($missingPackages -join ', ')"
|
|
}
|
|
if ($unexpectedPackages.Count -gt 0) {
|
|
throw "Unexpected NuGet packages: $($unexpectedPackages -join ', ')"
|
|
}
|
|
|
|
Write-Output "Verified $($actualPackageNames.Count) AtomUI NuGet packages for version $version"
|
|
|
|
# Consumer-visible package layout (tools/, buildTransitive/, build/, target-framework set). ApiCompat
|
|
# does not see these, yet they are the class of break that shipped undocumented in 6.1.9. Run this
|
|
# whenever a baseline is supplied; acknowledged changes live in package-layout-allowlist.json.
|
|
if (-not [string]::IsNullOrWhiteSpace($PackageValidationBaselineVersion)) {
|
|
$layoutVerification = Join-Path $PSScriptRoot "verification/verify-package-layout.ps1"
|
|
& pwsh -NoLogo -NoProfile -File $layoutVerification `
|
|
-PackageDirectory $PackageOutputDir `
|
|
-BaselineVersion $PackageValidationBaselineVersion
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Package layout verification failed against $PackageValidationBaselineVersion."
|
|
}
|
|
}
|