Issue with Build Profile in CI - ArgumentException Build profile is invalid

I recently update my project to Unity 6.
It only supports Windows Standalone, no other platforms installed.
Along the update i thought lets give the new Build Profiles a try to get rid of my custom scripts that are manipulating the PlayerSettings.

Set everything up and it works like a charm.
At least locally :sweat:

I have a CI setup with Github Runners that checkout the project and starts the build by executing unity as batchmode with a custom method as starting point.

In the method i load the correct BuildProfile via AssetDatabase.LoadAssetAtPath(ā€¦) and start a addressables build before finally calling BuildPipeline.BuildPlayer() with the new BuildPlayerWithProfileOptions where i set my locationPathName as well as the buildProfile.

For whatever reason i get on the Build Server the following error:
ArgumentException: Build profile is invalid at UnityEditor.BuildPipeline.BuildPlayer(UnityEditor.BuildPlayerWithProfileOptions buildPlayerWithProfileOptions)

I then looked at the source code of BuildPipeline.cs and found my exception:

public static BuildReport BuildPlayer(
      BuildPlayerWithProfileOptions buildPlayerWithProfileOptions)
    {
      BuildProfile buildProfile = buildPlayerWithProfileOptions.buildProfile;
      BuildProfileContext.activeProfile = !((UnityEngine.Object) buildProfile == (UnityEngine.Object) null) ? buildProfile : throw new ArgumentException("Build profile is invalid.");
      return BuildPipeline.BuildPlayer(BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(buildPlayerWithProfileOptions.locationPathName, buildPlayerWithProfileOptions.assetBundleManifestPath, buildPlayerWithProfileOptions.options));
    }

This would mean that my buildProfile seems to be null.
But the strangest part is that I have a null check for the BuildProfile that i load via AssetDatabase.LoadAssetAtPath(ā€¦) already before i start the addressables build that would throw an Exception and stop the build ealier.

As it works locally from within the editor, as well as via the batchmode i am kinda lost what the issue could be.

I have two ideas where someone maybe can help me double checking them.

  1. As i have the null check in my code as well but before the Addressables Rebuild, could it be that the instance get lost while building the Addressables?
    ā†’ I will try tomorrow to add another custom null check after the Addressables Rebuild and update the
    post depending on the outcome.

  2. As we checkout the project on the Gitrunner there is no cached Library Folder. So what is the default configured BuildProfile, or TargetPlatform? So what would i see selected if I oben the Build Profiles Window in a running Unity Instance there?
    Could it be that something goes wrong when setting the build profile while still the default setting is in place?

But the second option would be weird as i get exactly the Exception that is thrown in the BuildPlayer(BuildPlayerWithProfileOptions) Methodā€¦

Thanks in advance for help!

Hint: youā€™re not getting a NullReferenceException but an ArgumentException. Those are different. :wink:

Itā€™s telling you the ā€œargumentā€ (build profile) is ā€œinvalidā€ (whatever that means). Perhaps the build profile simply contains no scenes for some reason. Or there may be conflicting, mutually exclusive settings. Or you try to build for a platform whose module is not installed on the build machine (ie IL2CPP). Just some guesses.