Package CultMesh NuGet dependency closure
This commit is contained in:
parent
340df225d4
commit
bf9629000a
2 changed files with 110 additions and 0 deletions
17
docs/nuget-packaging.md
Normal file
17
docs/nuget-packaging.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# NuGet Packaging
|
||||
|
||||
CultLib publishes the managed dependency graph as separate packages. The leaf
|
||||
package is `GameCult.Mesh`; its NuGet dependencies preserve the CultMesh,
|
||||
CultNet, and CultCache ownership boundaries.
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\scripts\pack-nuget.ps1
|
||||
```
|
||||
|
||||
The command creates a local feed under `artifacts/nuget`, verifies that every
|
||||
internal dependency package exists at the same version, then restores and runs
|
||||
a clean .NET consumer using only `PackageReference Include="GameCult.Mesh"`.
|
||||
|
||||
The Unity distribution remains `org.gamecult.cultlib`, built by
|
||||
`scripts/build-unity-package.ps1`, because Unity consumes the managed assembly
|
||||
closure through UPM rather than NuGet restore.
|
||||
93
scripts/pack-nuget.ps1
Normal file
93
scripts/pack-nuget.ps1
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
param(
|
||||
[string] $Configuration = "Release",
|
||||
[string] $OutputDirectory = "artifacts\nuget",
|
||||
[switch] $SkipConsumerSmoke
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$outputRoot = if ([IO.Path]::IsPathRooted($OutputDirectory)) {
|
||||
$OutputDirectory
|
||||
} else {
|
||||
Join-Path $repoRoot $OutputDirectory
|
||||
}
|
||||
|
||||
$projects = @(
|
||||
"src\GameCult.Logging\GameCult.Logging.csproj",
|
||||
"src\GameCult.Caching\GameCult.Caching.csproj",
|
||||
"src\GameCult.Caching.MessagePack.Analyzers\GameCult.Caching.MessagePack.Analyzers.csproj",
|
||||
"src\GameCult.Caching.MessagePack\GameCult.Caching.MessagePack.csproj",
|
||||
"src\GameCult.Networking\GameCult.Networking.csproj",
|
||||
"src\GameCult.Mesh\GameCult.Mesh.csproj"
|
||||
)
|
||||
|
||||
if (Test-Path -LiteralPath $outputRoot) {
|
||||
Remove-Item -LiteralPath $outputRoot -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null
|
||||
|
||||
foreach ($project in $projects) {
|
||||
dotnet pack (Join-Path $repoRoot $project) -c $Configuration -o $outputRoot
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "NuGet pack failed for $project with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
$meshPackage = Get-ChildItem -LiteralPath $outputRoot -Filter "GameCult.Mesh.*.nupkg" |
|
||||
Where-Object { $_.Name -notlike "*.snupkg" } |
|
||||
Select-Object -First 1
|
||||
if (-not $meshPackage) {
|
||||
throw "GameCult.Mesh package was not produced."
|
||||
}
|
||||
|
||||
$version = [regex]::Match($meshPackage.Name, '^GameCult\.Mesh\.(.+)\.nupkg$').Groups[1].Value
|
||||
$expectedPackages = @(
|
||||
"GameCult.Logging.$version.nupkg",
|
||||
"GameCult.Caching.$version.nupkg",
|
||||
"GameCult.Caching.MessagePack.Analyzers.$version.nupkg",
|
||||
"GameCult.Caching.MessagePack.$version.nupkg",
|
||||
"GameCult.Networking.$version.nupkg",
|
||||
"GameCult.Mesh.$version.nupkg"
|
||||
)
|
||||
foreach ($package in $expectedPackages) {
|
||||
if (-not (Test-Path -LiteralPath (Join-Path $outputRoot $package))) {
|
||||
throw "NuGet dependency closure is missing $package"
|
||||
}
|
||||
}
|
||||
|
||||
if (-not $SkipConsumerSmoke) {
|
||||
$smokeRoot = Join-Path $repoRoot "artifacts\nuget-consumer-smoke"
|
||||
if (Test-Path -LiteralPath $smokeRoot) {
|
||||
Remove-Item -LiteralPath $smokeRoot -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Force -Path $smokeRoot | Out-Null
|
||||
$projectDocument = @"
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RestoreSources>$outputRoot;https://api.nuget.org/v3/index.json</RestoreSources>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="GameCult.Mesh" Version="$version" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
"@
|
||||
$program = @"
|
||||
using GameCult.Mesh;
|
||||
|
||||
var verse = CultMesh.Verse("nuget-smoke", "cultlib.pack");
|
||||
Console.WriteLine(verse.Context.VerseId);
|
||||
"@
|
||||
[IO.File]::WriteAllText((Join-Path $smokeRoot "Consumer.csproj"), $projectDocument, [Text.UTF8Encoding]::new($false))
|
||||
[IO.File]::WriteAllText((Join-Path $smokeRoot "Program.cs"), $program, [Text.UTF8Encoding]::new($false))
|
||||
dotnet run --project (Join-Path $smokeRoot "Consumer.csproj") -c Release
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "GameCult.Mesh NuGet consumer smoke failed with exit code $LASTEXITCODE"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "CultLib NuGet feed: $outputRoot"
|
||||
Write-Host "GameCult.Mesh: $version"
|
||||
Write-Host "Public package closure: $($expectedPackages.Count) packages"
|
||||
Loading…
Reference in a new issue