Repository navigation
fix(unity): build the Player when no subtarget given - #302
Conversation
Standalone builds without -standaloneBuildSubtarget handed Unity StandaloneBuildSubtarget.Default, so Unity reused the subtarget persisted in the project's Library. A Library cached from a Server build made later Player builds fail with "Dedicated Server support for <platform> is not installed".
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Set up the test harness scripts/test-build-subtarget.sh |
The script checks for dotnet, creates a temporary project, and defines Unity stubs for compilation. |
Run assertions in the workflow scripts/test-build-subtarget.sh, .github/workflows/tests.yml |
The harness checks subtarget results, exceptions, and warnings. It builds and runs the tests. The workflow invokes the script. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers: frostebite
Merge Risk: 
Minimal · up to 497af
-
The new tests cover subtarget resolution. No concrete issue requiring a fix before merge was established.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title "fix(unity): build the Player when no subtarget given" matches the main change. The PR makes a standalone build without -standaloneBuildSubtarget build the Player instead of the subtarget persisted in the project's Library. The title is short, specific, and follows a conventional-commit style. It does not cover the input validation, case-insensitivity, or non-standalone warning changes, which is acceptable.
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 unsupported.)
Full details: Description check
-
Explanation
The description is detailed and covers the change, user-visible behavior, implementation scope, testing, and verification results. It does not use the template headings or include the required checklist, but the missing items are non-critical because the required change information is present.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
The default build script lets users pick a standalone subtarget with
-standaloneBuildSubtarget Player|Server. When the flag was missing, it passedStandaloneBuildSubtarget.Default(0) to Unity. Unity'sBuildPipeline.BuildPlayer(2023.2 reference source) replacesDefaultwithEditorUserBuildSettings.standaloneBuildSubtarget, which is stored in the project'sLibrary, and writes the result back there. ALibrarythat once built a Server, for example one restored from a CI cache, therefore keeps building Servers. On a runner without the Dedicated Server module that fails withDedicated Server support for MacStandalone is not installed(a failing unity-builder job).This makes a standalone build without a subtarget build the Player, whatever the
Libraryremembers.Behaviour changes for users (Unity 2021.2+, default build script only)
-standaloneBuildSubtargeton a standalone target: builds the Player. Before, it built whatever subtarget the project'sLibrarylast used. If you relied on the editor's saved "Dedicated Server" setting, pass-standaloneBuildSubtarget Serverexplicitly.-standaloneBuildSubtarget Defaultkeeps the old behaviour.Headless,7): the build now fails withUnknown standaloneBuildSubtarget "…"; expected Player or Server.Before, it fell back to the persisted subtarget without saying so.serverworks).0, as it already was without the flag. Before,-standaloneBuildSubtarget Serveron Android passed1to Unity as that target's subtarget, where the value has a target-specific meaning rather than "Server".What changed
Input/BuildSubtarget.cs(new, with.meta):BuildSubtarget.Resolve(target, options)holds the rule above.Builder.cscalls it from theBuildPlayerOptionsinitialiser. The change is applied todist/default-build-scriptand to the twoplugins/unitycopies, so they stay in step.src/generated/embedded-assets.tsis regenerated.scripts/test-build-subtarget.sh(new, run in the Tests workflow) compilesBuildSubtarget.cswith the .NET SDK, at C# 9 as in Unity 2021.2, against minimal Unity stubs. The stubs' enum values come from Unity's reference source. It asserts ten cases, including both behaviour changes above.Verified locally
bun run test(357 pass, 0 fail),generate-embedded-assets.mjs --check,validate-platform-scripts.sh,shellcheckandactionlintall pass.Summary by CodeRabbit