Search Unity

Resolved Can't build Linux IL2CPP Standalone in batchmode

Discussion in 'Testing & Automation' started by Agoxandr, Apr 12, 2023.

  1. Agoxandr

    Agoxandr

    Joined:
    Aug 16, 2014
    Posts:
    52
    Unity 2021.3.22f
    Not sure if I'm going insane but building Standalone Linux using Windows 10 in batchmode just doesn't work for me. So I'm forced to run my powershell build script over remote desktop (which works) instead of running it through ssh.

    Is this fine or am missing something obvious? I have all the necessary packages installed. Just running -buildLinux64Player in batchmode doesn't work either.

    In the logs it never reaches this line
    Debug.Log("Switch active build target Standalone, StandaloneLinux64");

    which is strange. If I skip building Windows and start with building Linux it will just quit instantly.

    I also managed to make it work once somehow, but then the shaders for the URP decals were pink and flickering instead of showing.

    Code (CSharp):
    1. # Not using -batchmode because that just wont finish.
    2. .\Unity.exe -projectPath "C:\Users\shazbot\Documents\Final" -accept-apiupdate -executeMethod Editor.BuildCLI.Full | Out-Null
    3. if ($LASTEXITCODE -eq 1) {
    4.     Write-Output "Build failed. Further steps aborted."
    5.     Exit
    6. }
    Code (CSharp):
    1. using System;
    2. using UnityEditor;
    3. using UnityEditor.Build.Reporting;
    4. using UnityEngine;
    5. using UnityEngine.SceneManagement;
    6.  
    7. namespace Editor
    8. {
    9.     public class BuildCLI
    10.     {
    11.         public static void Full()
    12.         {
    13.             var scenes = new string[SceneManager.sceneCountInBuildSettings];
    14.             for (var i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
    15.             {
    16.                 var scene = SceneUtility.GetScenePathByBuildIndex(i);
    17.                 scenes[i] = scene;
    18.             }
    19.  
    20.             Debug.Log($"Include scenes: {string.Join(" ", scenes)}");
    21.             Debug.Log("Switch active build target Standalone, StandaloneWindows64");
    22.             EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone,
    23.                 BuildTarget.StandaloneWindows64);
    24.             Debug.Log("Build Windows IL2CPP");
    25.             const string winPath = "C:\\Users\\shazbot\\Documents\\Build\\WindowsIL2CPP Player\\Reconquer.exe";
    26.             var winReport =
    27.                 BuildPipeline.BuildPlayer(scenes, winPath, BuildTarget.StandaloneWindows64, BuildOptions.None);
    28.             if (winReport.summary.result != BuildResult.Succeeded)
    29.             {
    30.                 Debug.Log("Windows IL2CPP build failed.");
    31.                 EditorApplication.Exit(1);
    32.             }
    33.  
    34.             Debug.Log("Switch active build target Standalone, StandaloneLinux64");
    35.             EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone,
    36.                 BuildTarget.StandaloneLinux64);
    37.             Console.WriteLine("Build Linux IL2CPP");
    38.             const string linuxPath = "C:\\Users\\shazbot\\Documents\\Build\\LinuxIL2CPP Player\\Reconquer.x86_64";
    39.             var linuxReport =
    40.                 BuildPipeline.BuildPlayer(scenes, linuxPath, BuildTarget.StandaloneLinux64, BuildOptions.None);
    41.             if (linuxReport.summary.result != BuildResult.Succeeded)
    42.             {
    43.                 Debug.Log("Linux IL2CPP build failed.");
    44.                 EditorApplication.Exit(1);
    45.             }
    46.  
    47.             EditorApplication.Exit(0);
    48.         }
    49.     }
    50. }
     
  2. Agoxandr

    Agoxandr

    Joined:
    Aug 16, 2014
    Posts:
    52
    Batch mode can't switch build targets.
     
    kayy likes this.