Bricks: NuGet package dependencies (restore, lock file, editor loading)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 12/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- csharp
- 領域
- build-system, devtools
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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)
- 主要言語
- C#
- スター
- 1
- フォーク
- 1
- 平均マージ
- 1時間 29分
- マージ済み PR(30日)
- 38
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MASS4ORG/Turian のほかの issue
-
c:assets p:low size:XS t:task
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
c:build c:editor p:medium size:XL t:feature
難易度 5/5 1週間以上 初心者へのやさしさ 5/100
メンテナーはふだん 1 日以内に返信
-
c:build p:medium size:XL t:refactor
難易度 5/5 1週間以上 初心者へのやさしさ 8/100
メンテナーはふだん 1 日以内に返信
-
c:build c:ui p:low size:L t:refactor
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
-
c:assets c:build p:low size:S t:refactor
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
メンテナーはふだん 1 日以内に返信
MASS4ORG/Turian の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ClickHouse/clickhouse-cs#689 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 7 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
vchelaru/FlatRedBall2#1481 ·
メンテナーはふだん 1 日以内に返信
-
ai-chat bug trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area-signalr
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
dotnet/aspnetcore#69842 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信