Reproduction steps:
1. Open the attached project “Unity Extensions”
2. Build the project
Expected result: Build is successful
Actual result: Unity Editor crashes
Reproducible with: 2021.3.13f1
Couldn't test with: 2020.3.41f1, 2022.1.22f1, 2022.2.0b15, 2023.1.0a18 (Compiler errors: “EditorUserBuildSettings.il2CppCodeGeneration' is obsolete”)
Reproducible on: macOS Catalina 10.15.7 (Intel), Windows 10 (by user)
First few lines of stack trace:
0x00007ff63ca8896a (Unity) CollectAllSerializeReferenceTypesAndPersistentCallTargets
0x00007ff63ca8accd (Unity) CompileGameResourcesFolderDependencies
0x00007ff63d7a284b (Unity) BuildPlayerData
0x00007ff63d7ad007 (Unity) DoBuildPlayer_Build
0x00007ff63d7ab8e6 (Unity) DoBuildPlayer
Summary based on investigation:
The crash is related to two ScriptableObjects where the source file name does not match the class name. The Assets for these ScriptableObjects are stored in a Resources folder so they are included in the build.
When the source file is renamed to match the class name the crash does not occur. Unity shows a warning about the broken state of these objects when the project is opened.
The project may not upgrade smoothly to later versions of Unity, but this bug almost certainly exists in later versions as well. It was also reported with a 2022 project (IN-27866)