Bricks: NuGet package dependencies (restore, lock file, editor loading)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 12/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- csharp
- Domain
- build-system, devtools
Research direction
Start from CsProjectGenerator.AddBrickPackages and BrickAssemblies.Load to see how nuget maps become PackageReferences and how precast DLLs load today. Then read the csproj files of org.mass4.turian.ui and org.mass4.turian.physics.bepu for the hand-listed DLL copies. Done means restore-driven loading, version unification, a lock file and a drift test all work. This is design work, so discuss the approach with maintainers first.
Written by the indexing model from the issue text.
Description
Current State
Bricks declare NuGet dependencies in a nuget map in package.json. Generated game projects already turn that map into PackageReference items (CsProjectGenerator.AddBrickPackages). The editor, however, cannot load a precast brick assembly that depends on a package it doesn't already reference itself. BrickAssemblies.Load only loads the DLLs in Precast~/lib into the default load context; nothing probes package folders.
Bricks work around this by copying third-party DLLs into Precast~/lib from their csproj:
org.mass4.turian.uicopiesGuinevere.dllandGuinevere.Styling.dllfrom its references. It depends onMASS4.Guinevere6.*, a floating version. SkiaSharp is in itsnugetmap, and the editor loads it only because the editor references SkiaSharp itself.org.mass4.turian.physics.bepu(#64) copiesBepuPhysics.dllandBepuUtilities.dlland has nonugetmap.
Hand-listed DLL copies are a stopgap. If user bricks can't depend on NuGet packages, the brick ecosystem fails. The missing piece is tooling (restore plus probe-path wiring), not a .NET constraint.
Goal
A brick's nuget map is the single source of truth for its package dependencies. The editor restores the map, loads the packages, and resolves version conflicts between bricks; game export ships the resolved packages. Builds are reproducible through a lock file.
Design decisions
- Restore: one generated stub project merges the
nugetmaps of all loaded bricks, anddotnet restorerestores it. Use one stub for all bricks, not one per brick, so there is one lock file and the conflict policy has a single place to live.dotnet restoreis preferred over in-processNuGet.Protocol, which would add a dependency to the editor. - Hermetic cache:
dotnet restorewrites to~/.nuget/packagesby default. Next to the stub project, generate aNuGet.configwith<config><add key="globalPackagesFolder" value="Library/NuGet" /></config>, or setNUGET_PACKAGESfor the restore process, so packages live in the project's cache. Pick the exact folder (Library/NuGetor.Cache/NuGet) to match the existing project layout. - Lock file: generate with
RestorePackagesWithLockFile=true. Restores during editor load and in CI use--locked-mode, so a committedpackages.lock.jsonis authoritative. - No floating versions: reject floating versions (
2.5.*,6.*) in bricknugetmaps, or resolve them at restore time and write the pin back. Floating versions combined with a lock file is how drift creeps in. Migrate the UI brick's6.*Guinevere reference. - Version unification across bricks:
- Within a major version, the highest requested version wins.
- Different major versions are a hard error that names both bricks and both versions.
- Ordering follows NuGet's SemVer 2.0 rules, prerelease labels included:
2.5.0-beta.33is above2.5.0-beta.9, and a release is above its prereleases. Compare withNuGetVersion, never with string>.
- Editor loading:
- Emit a
.deps.jsonbeside each precast brick assembly; the stub restore already produces the data. - Load each brick through an
AssemblyDependencyResolver, which gives the transitive closure and per-context version selection. - A
Resolvinghandler is only a fallback. - Every brick's resolver must see the unified restore's result, so two bricks never load two versions of one package.
- Emit a
Precast~/libcommit policy:- Keep
Precast~/libcopies as a generated artifact (restore, then copy), never a hand-maintained list. - First-party bricks commit the generated copy, so a fresh clone loads offline and CI needs no restore for editor-only paths.
- Add a drift test that restores from the map and compares against the committed DLLs by assembly and package version, not file hash, so build noise doesn't cause false failures. Run it alongside
BrickVerifier.
- Keep
- Scope: pure managed packages only. Packages with native assets, or transitive native assets, are out of scope and need extra handling later. Brick READMEs must not promise them.
Tasks
- Generate the merged stub project (all loaded bricks'
nugetmaps), itsNuGet.configwith a project-localglobalPackagesFolder, andRestorePackagesWithLockFile. - Run
dotnet restorewhen bricks load and when they are installed or changed; use--locked-modewhen a lock file exists. Report restore failures in the Output panel and the CLI. - Unify versions across bricks: highest within a major, a hard error across majors, NuGet SemVer prerelease ordering (
NuGetVersion). - Reject floating versions in
nugetmaps, or pin them on restore. - Load precast brick assemblies through
AssemblyDependencyResolverwith a generated.deps.json; keep aResolvingfallback. - Generate
Precast~/libthird-party copies from thenugetmap (restore, then copy), replacing the hand-listed copies in the UI and physics bricks' csproj files. - Add a drift test: restore the map and compare the committed
Precast~/libDLLs by version. - Migrate
org.mass4.turian.ui: pin Guinevere and move it into thenugetmap. - Migrate
org.mass4.turian.physics.bepu: add"nuget": { "BepuPhysics": "2.5.0-beta.33", "BepuUtilities": "2.5.0-beta.33" }. - Game export: confirm resolved packages are copied through the existing
PackageReferencepath, and that server builds still leave out client-only bricks' packages. - Docs: a brick authoring section on NuGet dependencies, covering the lock file, the version policy, and the pure-managed limit.
Acceptance Criteria
- A brick that depends only on a NuGet package, with no DLLs in
Precast~/lib, loads in the Studio and the CLI, and its types work in play mode. - Two bricks asking for
X 1.2.0andX 1.4.0both load1.4.0. Asking forX 1.xandX 2.xfails with an error naming both bricks. 2.5.0-beta.33is chosen over2.5.0-beta.9.- A committed
packages.lock.jsonis enforced: a change to anugetmap without updating the lock fails in locked mode. - A fresh clone opens offline with the first-party bricks.
- The drift test fails when a
nugetmap and the committedPrecast~/libdisagree. - The UI and physics bricks no longer hand-list DLL copies.
- Exported games run with brick packages; server builds stay free of client-only packages.
Related
- #64 (physics backend; the Bepu brick currently vendors its DLLs)
- Brick manifest platform allow-list and per-platform NuGet (#248)
- Dominant language
- C#
- Stars
- 1
- Forks
- 1
- Avg merge
- 1h 29m
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from MASS4ORG/Turian
-
c:assets p:low size:XS t:task
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
c:build c:editor p:medium size:XL t:feature
Difficulty 5/5 Over a week Newbie friendliness 5/100
Maintainers usually reply within 1 day
-
c:build p:medium size:XL t:refactor
Difficulty 5/5 Over a week Newbie friendliness 8/100
Maintainers usually reply within 1 day
-
c:build c:ui p:low size:L t:refactor
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
-
c:assets c:build p:low size:S t:refactor
Difficulty 5/5 Over a week Newbie friendliness 15/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Devolutions/UniGetUI#5541 ·
Maintainers usually reply within 1 day
-
agentic-workflows Needs: Triage :mag:
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
[誤判定]Openlinux アプリ: ブラウザー 再現済み 要トリアージ 誤判定
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
yksr-melt/Meltype#853 · 2 comments ·
Maintainers usually reply within 1 day
-
S: Untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Trauma-Station/Trauma-Station#5073 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day