Repository navigation
feat(build)!: exclude Unity-MCP from player builds unless UNITY_MCP_RUNTIME is set; Unity 7 compile fix - #1217
Open
IvanMurzak wants to merge 13 commits into
Open
IvanMurzak wants to merge 13 commits into
IvanMurzak wants to merge 13 commits into
Conversation
…NTIME is defined Player builds now contain none of the plugin's or the extensions' runtime assemblies and none of their NuGet DLLs by default; the Editor always has them. - Every player-compiled asmdef (plugin Runtime, TestFiles, PlayMode tests, the ten extensions' Runtime and PlayMode tests, the extension template, the test projects' RuntimeTests) carries the define constraint "UNITY_EDITOR || UNITY_MCP_RUNTIME". - NuGet DLL importers: runtime DLLs get the same define constraint; the runtime set is the closure of the includeInBuild roots through the cached .nuspec files and the DLLs' own assembly references (a minimal ECMA-335 AssemblyRef reader), so the Roslyn stack of csharp-exec no longer ships in players. A NuGet DLL that a player DLL outside the install folder references (a user's own System.Text.Json -> System.Text.Encodings.Web) stays in every build. ConfigureAll runs on every domain reload, which migrates existing projects. - PlayerBuildOptIn (DependencyResolver assembly): the opt-in from Player Settings, the active Build Profile and BuildPlayerOptions.extraScriptingDefines (captured by a BuildPlayerProcessor); the main window's "Include in game builds" toggle sets it for every build target. - PlayerBuildCheck: every player build logs whether it includes Unity-MCP; an excluding build gets an actionable hint for CS0234/CS0246 on Unity-MCP types (and System.Text.Json), a warning for importers not migrated yet (CI .meta files) and a build error when a foreign DLL needs a constrained one. - LinkExtractor merges Unity-MCP's link.xml only into builds that include it and always clears a stale merged folder first. - The NuGet gate generation moves to UNITY_MCP_DEPS_54 (no pin change), so an extension built for an earlier plugin (no constraint) is skipped instead of breaking a player build; extensions settled to 2.1.9. - extensions.unity.playerprefsex removed: Editor UI state moves to per-project EditorPrefs and a value saved under the PlayerPrefsEx key is moved over on first read. - Unity 7: the Lighting RQL module and tests no longer use the removed ProgressiveCPU. - Docs (custom-tools, ci-disable, README, all translations), CHANGELOG, extension dev doc; EngineFree tests for the constraints, the classification and the reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opt-in Written by NuGetPluginConfigurator when Unity 2022.3.62f3 loaded the project outside CI: runtime DLLs carry UNITY_EDITOR || UNITY_MCP_RUNTIME, the Roslyn stack is editor-only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Test Framework does The player compile set follows the player defines: a PlayMode test assembly behind UNITY_EDITOR || UNITY_MCP_RUNTIME dropped out of it, and its tests were tagged EditMode (RqlTestsSourceTests failed on 2022.3.62f3). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mporter state; settings resolve once - NuGetBuildInclusion: PackageClosure and AssemblyClosure use one Closure walk. - NuGetPluginConfigurator: ClassifyInstalled returns InstalledDll (name, path, inclusion, Unity-provided), so ConfigureDll no longer recomputes the assembly name and the resolver lookup per DLL; ExpectedConstraints takes only the inclusion; Misconfigured (bool?) became StateOf (ImporterState); the player targets are every non-obsolete BuildTarget instead of a hand list; cheap path checks first. - UnityAssemblyResolver.Provides and NuGetInstallManifest.AssemblyNameOf replace the copies in the configurator and NuGetPackageInstaller. - EditorPrefsValue: one Resolve that builds the project key and moves the PlayerPrefsEx value once per key and session (was two HasKey calls on every foldout read); one legacy-move path for both types. - PlayerBuildOptIn.HowToInclude is the one wording of how to opt in; SetInPlayerSettings reuses IsDefinedInPlayerSettings. LinkExtractor uses ServerBinaryUpdateWatcher.UnityMcpPackageName. - AssemblyReferenceReader: one null-terminated string reader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…opt-in, settings scope, docs Findings of the report-only review fan-out (resolver/build, gating/extensions, UI/tests) and of the F-scenario build on 6000.6.7f1, fixed: - PlayerBuildCheck: the CS0234/CS0246 hint also matches the failing source line (6000.6 reports only "The type or namespace name 'com' could not be found", so no hint was logged). - PlayerBuildOptIn: the Server subtarget comes from the build report, not the Editor setting (a scripted dedicated-server build was judged by the Standalone defines: link.xml skipped, IL2CPP stripping); a target whose defines cannot be read no longer counts toward the toggle state. - NuGetPluginConfigurator: an Any Platform DLL outside the install folder counts as going into players only when some player target is not excluded; comments on what "Unity provides" means. - commands/extensions.py prepare: the test projects' Standalone defines include UNITY_MCP_RUNTIME, so the standalone CI leg builds the plugin's PlayMode tests into its player again (it ran none). - EditorPrefsValue: scoped by company and product name like the Editor PlayerPrefs it replaces (copies of a project share a productGUID); the PlayerPrefsEx value is copied, not deleted (downgrades). - Guidance is #if UNITY_EDITOR || UNITY_MCP_RUNTIME (code still runs in Editor Play mode): docs in all languages, the hint, the toggle tooltip, CHANGELOG. CHANGELOG: downgrade steps, game code that used our DLLs, projects that used PlayerPrefsEx themselves. - Stale AGENTS/README lines about game builds; PackageManagerSettings scope; test robustness. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…th the CPU lightmapper) Found by re-running the EditMode suite on 7000.0.0a11 after the review fixes: RQL has no 'lightmapper' member there (LightingSettings.lightmapper is obsolete; EditorGraphicsSettings .defaultLightBaker picks it). Lighting tests: 7000.0.0a11 34 passed / 3 skipped, 2022.3.62f3 36 passed / 1 skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ng a reimport loop on upgrade A project configured by the previous plugin has Unity-provided DLLs that went into builds (Any Platform, Exclude Editor). The player opt-in makes System.Collections.Immutable and System.Reflection.Metadata editor-only, so on an Editor that provides them (Unity 6.6) they are disabled entirely. That path turned Any Platform off but left Exclude Editor set, while the change check compares it with false: the DLL was reconfigured and reimported on every domain reload, and the Editor recompiled without end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ed importer field is now written in both branches, so ConfigureDll converges after one pass from any prior state; no other reconfigure oscillation found) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tional-unity-mcp-build - Gate generation: main released UNITY_MCP_DEPS_54 (core 1.16.0, extensions 2.1.9, published without the player constraint), so the branch moves to 55 everywhere, and `extensions.py settle` moves the extensions to 2.1.10. - com.IvanMurzak.Rql is a runtime package now: its DLL importers (written by Unity 2022.3.62f3) carry the player opt-in; Runtime asmdef keeps main's Rql references and versionDefines, loses PlayerPrefsEx, keeps the constraint. - RqlRuntime decided which modules are Editor-only by "not compiled into players", which follows the player defines: without the opt-in every gated runtime module would be left out of Play Mode. It asks for the Editor-only flag instead (as RqlTests does). - EditorPrefsValue: the PlayerPrefsEx settings of 1.16 are migrated too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aged stripping Medium/High needs a link.xml Found by running the docs game end to end (built player, real gamedev-mcp-server, real MCP client): with stripping Medium or High the linker drops the game's tool classes (reflection only) and the game connects with no tools, on main too. An Assets/link.xml that preserves the tools' assembly fixes it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sting Without the player opt-in a project with no code of its own compiles nothing into players, so the set was empty: on Unity 6.6 and 7 our copies of 13 assemblies Unity provides (System.Text.Json, System.Memory, ...) were enabled in the Editor, and were reconfigured and reimported again with the first script or the opt-in. The Editor compile of the same assemblies answers instead: measured equal for our DLLs on 2022.3.62f3, 6000.6.7f1 and 7000.0.0a11. An only-plugin project on 6000.6.7f1 / 7000.0.0a11: 13 importers reconfigured on each toggle before, 0 after. Provides is the only entry point; its halves are private. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…and docs match the merged state - RqlRuntime.EditorOnlyByAssemblyName: RqlTests asked the compilation pipeline with its own copy of the rule. - NuGetConfig / NuGetPackage: the generation text names 55, IncludeInBuild says what it means with the player opt-in. - LinkExtractor comments and CHANGELOG: our link.xml keeps engine types for RQL too (main's #1216). - PlayerBuildCheck: Rql is one of our names for the compile-error hint. - docs: the runtime RQL tests in a player need the opt-in (`extensions.py prepare` adds it); why the generation moved. Skipped: deriving OurNames from ClassifyInstalled, IFilterBuildAssemblies instead of SourcesFor, IUnityLinkerProcessor instead of the merged link.xml, one Expected() for importer state, caching nuspec / AssemblyRef reads (redesigns of the reviewed feature); the leftover extensions.unity registry scope in READMEs and test projects (harmless, older plugins need it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mmitted importers tested, needed DLL in no player Report-only review fan-out (resolver/build hooks, gating/extensions/merge, runtime RQL/UI/tests) over origin/main...HEAD, fixed: - docs (custom-tools, README, 7 languages): the "Add a tool" recipe put an Editor tool where it also compiles into a player build, which now has no Unity-MCP; the chess sample gets the #if it is said to need. - The 'Include in game builds' label was clipped to the 85 px form column. - PlayerOptInTests: the committed DLL importers match the classification (fails on main's Rql importers, which the merge would have shipped in every player). - PlayerBuildCheck: a DLL every build needs that is in no player is reported too (CI with committed metas). - AssemblyReferenceReader: no allocation from an unvalidated row count. Not changed (nits / owner decisions): CI never builds the default player (workflow change), Unity-Tests metas are not migrated, an asmdef behind UNITY_EDITOR only counts as runtime in Play Mode, PlayerPrefsEx unique-key mode. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BREAKING: Unity-MCP is now excluded from player (game) builds by default. This covers our runtime code, the runtime assemblies of the extensions, and every NuGet DLL the plugin brings. To ship it in a game, enable Include in game builds in
Window/AI Game Dev, or defineUNITY_MCP_RUNTIME. The define can come from Player Settings, a Unity 6 Build Profile, orBuildPlayerOptions.extraScriptingDefines. The Editor always has Unity-MCP.Player asmdefs (plugin Runtime/TestFiles/Tests.Runtime, all 10 extensions, the template, Unity-Tests) get the define constraint
UNITY_EDITOR || UNITY_MCP_RUNTIME.NuGet DLLs get the same constraint in their PluginImporter, in one of three classes:
Existing projects are migrated by reconfiguring the importers.
LinkExtractormerges our link.xml only into builds that include Unity-MCP. Without this, IL2CPP builds that exclude it pulled in Unity's own Microsoft.Extensions.* copies.Build check logs INCLUDED or EXCLUDED and where the opt-in came from. Two failures get actionable messages:
#if UNITY_EDITOR || UNITY_MCP_RUNTIMEhint);The
extensions.unity.playerprefsexdependency is removed. Its only users were Editor windows. Settings move to EditorPrefs, keyed per project, and are migrated from the old keys, which are left in place.Gate generation is
UNITY_MCP_DEPS_55(main released 54 with core 1.16.0 and extensions 2.1.9, which have no player constraint), so an old extension Runtime asmdef is skipped and cannot break a player build. The first-party extensions go to 2.1.10 and must be released together with a bumped core.Unity 7: the Lighting module and its tests no longer use the removed
Lightmapper.ProgressiveCPU. Before, main failed with CS0619 on 7000.0.0a11.Docs in 7 languages (custom-tools runtime section, ci-disable, README) and a BREAKING CHANGELOG entry.
Merged with main (RQL in players, 1.16.0):
com.IvanMurzak.Rqlfollows the opt-in (importers, link.xml only in including builds).RqlRuntimeno longer decides "Editor-only" from the player compile set. "Unity provides" no longer depends on a player assembly existing.Verification of 85604de (IvanPC, real builds, real
gamedev-mcp-server9.6.5, official MCP SDK client)Assets/link.xmlfixes it (34/34 on five versions), now documented.error CS, and a mutating plus a reading call per extension in a live Editor, checked through the Unity API and on disk, on all six versions. Their EditMode tests all pass on 2022.3, 6000.6 and 7000. OFF players equal a no-plugin control with the same Unity packages on all six versions.Not tested: running on Android (no device connected), iOS, Dedicated Server, 6000.5.
Stages
Do not merge yet: the owner will verify manually first. Releasing requires the core and all extensions together through the train.
🤖 Generated with Claude Code