Bricks: NuGet package dependencies (restore, lock file, editor loading)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 12/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- build-system, devtools
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- C#
- Estrellas
- 1
- Forks
- 1
- Merge medio
- 1 h 29 min
- PR fusionados (30 d)
- 38
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MASS4ORG/Turian
-
c:assets p:low size:XS t:task
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
c:build c:editor p:medium size:XL t:feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 5/100
Los mantenedores suelen responder en 1 día
-
c:build p:medium size:XL t:refactor
Dificultad 5/5 Más de una semana Aptitud para principiantes 8/100
Los mantenedores suelen responder en 1 día
-
c:build c:ui p:low size:L t:refactor
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
Los mantenedores suelen responder en 1 día
-
Brick extraction: OBJ importerAbiertoc:assets c:build p:low size:S t:refactor
Dificultad 5/5 Más de una semana Aptitud para principiantes 15/100
Los mantenedores suelen responder en 1 día
Todos los issues de MASS4ORG/Turian
Issues similares
-
S: Untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
Trauma-Station/Trauma-Station#5058 ·
Los mantenedores suelen responder en 1 día
-
:books: documentation untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
documentation good first issue hacktoberfest
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
good first issue help wanted ready-for-human
Dificultad 2/5 Medio día Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día