Skip to content

fix(unity): call BuildPlayer without dynamic - #306

Open
webbertakken wants to merge 1 commit into
game-ci:mainfrom
webbertakken:fix/windows-legacy-build-dynamic
Open

webbertakken wants to merge 1 commit into
game-ci:mainfrom
webbertakken:fix/windows-legacy-build-dynamic

Conversation

@webbertakken

Copy link
Copy Markdown
Member

Note: This PR was written by my clanker. While I try to verify its steps as much as possible, it might not be 100% correct.


Builds on the Windows editors of Unity 2019 and 2020 fail within a second, with Error building player because build target was unsupported. It happens for every target, including the Windows host target. The game-ci/docker test workflow hits it on all 25 Windows jobs from 2019.3 to 2020.3, for example this run on main. Ubuntu editors of the same versions, and Windows editors from 2021.3 up, build fine.

The cause is the dynamic buildPlayerOptions in Builder.BuildProject. On these Windows editors, the BuildPlayerOptions passed through dynamic reaches Unity corrupted. I compared the two in the same editor session (diagnostic run, Windows 2019.4):

  • The same options, built through a typed BuildPipeline.BuildPlayer(options), succeeded three times in a row. That included after setting PlayerSettings.bundleVersion and PlayerSettings.macOS.buildNumber as VersionApplicator does.
  • The same options, passed as dynamic, threw InvalidOperationException: The build target does not support build appending. The options never set AcceptExternalModificationsToPlayer.

Before that, an earlier diagnostic showed the target as supported, licensed and loaded at editor start. So the image, the licence and the build path aren't the cause.

Changes

  • Each branch keeps its options statically typed and captures the call in a Func<BuildReport>, so BuildPlayer is never bound through dynamic. Build profiles and the addressables step behave as before.
  • Applied to dist/default-build-script and to the two identical copies under plugins/unity.

Verification

  • This run used this branch's UnityBuilderAction as the custom buildMethod, through the released CLI. All four jobs, Windows 2019.4.41f2 and 2020.3.49f1 with StandaloneWindows64 and Android, log Build succeeded!. They fail on main today.
  • All three copies compile with Mono's mcs against Unity 2022.1's UnityEditor.dll/UnityEngine.dll, with and without UNITY_2021_2_OR_NEWER. I could not compile the UNITY_6000_0_OR_NEWER branch locally. Its change mirrors the other branch.

Passing BuildPlayerOptions through a dynamic variable corrupts it on the
Windows editors of Unity 2019 and 2020: the build fails at once with
"Error building player because build target was unsupported", or with
"The build target does not support build appending". Capture the typed
options in a Func<BuildReport> per branch instead.
@coderabbitai

coderabbitai Bot commented Nov 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters: 3

  • dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs is excluded by !**/dist/**
  • plugins/unity/dist/unity-builder/dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs is excluded by !**/dist/**
  • plugins/unity/src/unity-builder/dist/default-build-script/Assets/Editor/UnityBuilderAction/Builder.cs is excluded by !**/dist/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e172072c-3c94-4902-9a85-86d85a469a16

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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.

Share

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant