- 
          
- 
        Couldn't load subscription status. 
- Fork 297
Description
Context
Enhancing #674 to cover more use cases.
Unity 6000+'s new feature "build profile" comes with multiple benefits:
- Allows to override project/build configurations per profile
- Allows to compile the project with profile-specific preprocessors before the build function is invoked
Current implementation by @MichaelBuhler (5eccc32) covers 1, but not 2.
Calling BuildProfile.SetActiveBuildProfile() during build script will not apply preprocessors, as documented here:
[...] when the Editor runs in batch mode, it runs “headless”, so there is no editor loop which would cause it to recompile with the new scripting symbols. Because of this, you should not use Editor scripts to set scripting symbols within a batch mode CI server because the scripts will not be recompiled, so they will not be applied.
It'll affect projects that manage code stripping like this:
#if PROFILE_A_LOADED
using ProfileA.Specific.Module;
ProfileA.Specific.Module.DoSomething();
#endifWe can cover this by passing buildProfile to -activeBuildProfile. In previous discussion, we went over compatibility mitigation:
- We continue to use targetPlatformto identify which Docker image to pull.
- If buildProfileis given by user, we pass it to-activeBuildProfile; otherwise we passtargetPlatformto-buildTarget.
- In case users made a mistake to specify a mismatching pair of targetPlatformandbuildProfile, build may fail (undefined behavior).
Regarding 3, previous discussion went over the possibility of reading the profile (yaml). I personally feel like not doing it because the file content format is not documented and it's a fairly new feature.
There was another compatibility issue surrounding the default build function but @MichaelBuhler has gracefully implemented a branching logic.
Suggested solution
Current implementation passes buildProfile to -customBuildProfile. Maybe we can simply reroute it to -activeBuildProfile but maybe I'm not seeing other compatibility issues?
Considered alternatives
Running two passes of unity-build action: (1) run the action with a function that sets active build profile and (2) run the action again with another function that actually runs the build.
Additional details
The -activeBuildProfile's behavior (that it invokes script compilation before -executeMethod function call) is actually not officially documented as far as I searched over their API documentation, but I believe that they just forgot to mention it. I've submitted a ticket to their documentation page assuming they ever read those.