Command line builds are not rendering graphics right, building from Editor UI renders correct.

I’m working on a simple multiplayer project. I have a build system that I use to build the game client and server. I’ve made it script I can call it from the menu. I wanted to automate the build in a CI/CD pipeline and everything was going smoothly until I discovered the client wasn’t rendering as expected. However my client and server function as expected, aside from this rendering issue. I can get around this by building from the UI, but I want to automate this process and I am not sure what I am doing wrong.

I’m currently using Unity 2021.1.3f1.

When I run my build script (below) from this menu in the editor, I get the expected result (yellowish walls and a white ground):


When I run the same script from powershell, the materials do not render correctly (everything is brownish):

& "C:\Program Files\Unity\Hub\Editor\2021.1.3f1\Editor\Unity.exe" -projectPath ".\MyXXXUnityProject\" -executeMethod BuildSystem.BuildClientWindows

 public class BuildSystem
{
    [MenuItem("Build/BuildAll")]
    public static void BuildAll()
    {
        BuildServerWindows();
        BuildClientWindows();
    }

    [MenuItem("Build/BuildServer")]
    public static void BuildServerWindows()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
        buildPlayerOptions.locationPathName = "Builds/Server/Windows/Server.exe";
        buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
        buildPlayerOptions.options = BuildOptions.EnableHeadlessMode;
        BuildPipeline.BuildPlayer(buildPlayerOptions);
    }

    [MenuItem("Build/BuildClient")]
    public static void BuildClientWindows()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
        buildPlayerOptions.scenes = new[] { "Assets/Scenes/SampleScene.unity" };
        buildPlayerOptions.locationPathName = "Builds/Client/Windows/Client.exe";
        buildPlayerOptions.target = BuildTarget.StandaloneWindows64;
        BuildPipeline.BuildPlayer(buildPlayerOptions);
    }
}

Digging more I found an error that occurs when the build happens from command line but not when I execute through the UI manually. The error seems to have to do with visual scripting, so I am not 100% certain it is related. Any advice would be awesome! I really want to get builds working command line.

Unity.VisualScripting.BoltCore.get_Paths () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Plugin/BoltCore.cs:41)
Unity.VisualScripting.AotPreBuilder.get_linkerPath () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:28)
Unity.VisualScripting.AotPreBuilder.DeleteAotStubs () (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:85)
Unity.VisualScripting.AotPreBuilder.OnPostProcessBuild (UnityEditor.BuildTarget target, System.String pathToBuiltProject) (at Library/PackageCache/com.unity.visualscripting@1.5.2/Editor/VisualScripting.Core/Platforms/AotPreBuilder.cs:40)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[ ] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[ ] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
UnityEditor.Build.BuildPipelineInterfaces+AttributeCallbackWrapper.OnPostprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass17_0.<OnBuildPostProcess>b__1 (UnityEditor.Build.IPostprocessBuildWithReport bpp) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at <1798d6bccd2b44b2854be2fbcc2463b3>:0)
UnityEditor.BuildPipeline:BuildPlayer(BuildPlayerOptions)
BuildSystem:BuildClientWindows() (at Assets/Editor/BuildSystem.cs:67)
BuildSystem:BuildAll() (at Assets/Editor/BuildSystem.cs:24)

We also have this issue, did you find a solution?

I have not yet, but I plan to post the solution once I have it. Can you please let me know if you figure it out?

We solved this yesterday by adding a default lighting settings object to the scene lighting settings (Window->Rendering->Lighting). We had multiple scenes and one was missing a settings object. It seems if the settings field is left Missing, then behaviour is undefined and must be treated differently in different contexts. Just by specifying defaults, it then seems consistent between builds.