Search Issue Tracker

Won't Fix

Votes

0

Found in

2020.3.44f1

Issue ID

UUM-23155

Regression

No

[BatchMode] Script compilation during Initial Script Refresh fails because of Define Symbols changed

-

Steps to reproduce:
1. Open the attached user's project "define-symbols-bug.zip"
2. Add the project as a local repository on Github
3. Perform an initial commit of the project files
4. Run this command in Command Prompt: Unity.exe -quit -batchmode -nographics -projectPath "PATH" -buildTarget Android -executeMethod Bar.BuildWithoutFoo -logfile log1.txt
5. To confirm that the build actually happened, check the "Out" Folder in the project directory to see the built APK
6. In Github dekstop app check and see if the FOO define symbol attribute was removed from the ProjectSettings file
7. Type "git reset --hard" in CMD in your root project folder
8. Go into your project directory and modify "Assets/Code/CodeEditor/Bar.cs" (add empty lines) to force its recompilation
9. Repeat step 4 again and see that the batch build failed

Expected results: batch build doesn't fail
Actual results: batch build fails

Reproducible on: 2020.3.44f1
Not reproducible on: 2021.3.17f1, 2022.2.3f1, 2023.1.0a25

Notes:
- The first build removes FOO define symbol and builds the project without building CodeFoo.dll assembly which is constrained on FOO.
- The second build detects Bar.cs was modified and reimports it during Initial Script Refresh phase. FOO is defined so it compiles code under #if FOO but the dependency CodeFoo.dll is not in the assembly cache thus this build fails.
- Issue is not reproducible on macOS

  1. Resolution Note:

    Unfortunately, it is a known limitation of the build pipeline today: project settings that can impact both editor and standalone player code are set atomically, to avoid situations where the editor code used in the batch has different define symbols / build targets defined as in the standalone player they are building.
    In non-batch mode, it is usually not an issue, as changing such a setting triggers a rebuild on next frame, so when you actually build the standalone player, your editor code is already running with the correct buildtarget / define symbols.

    To workaround this, most of our CI scripts that build standalone players are actually written with 2 batch invocations:
    - 1st one configure the projects (sets define symbols, build target, scripting backend etc.)
    - 2nd only runs the player build

    The rationale here, is that we have customers who have define symbols that both impact their build script code and the runtime code produced in players. Somehow, we need to keep them in sync.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.