Search Unity

Resolved Command line issue

Discussion in 'Testing & Automation' started by TaleOf4Gamers, Mar 16, 2019.

  1. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Warning, this will probably be not very legible at times, been messing around for a few hours now and am getting a migraine.

    Hey,

    I just started working with Jenkins. I have setup a simple job to check my Github repo every 5 minutes (Yes, I could trigger it with a webhook) and this works fine, it detects changes.

    However on my machine with Jenkins it does seem to launch Unity (In the background at least) but does not appear to build the game. I can see that it does open by looking in Task Manager and the usual compilation processes start up such as VBCSCompiler. However after doing what seems to be building the game, there is no build folder and no game and as to be expected, Jenkins ends with a failure.

    What is weird is that I am not running in batch mode so it should be visible while building but isn't. I also found that it would say that to make sure that the project folder is able to be written to and read from but I found the Jenkins workspace folder to be read-only. I gave User full control of the Jenkins folder and that seems to fix the read-only problem however it still would not give me a build at the end.

    Here is the super simple batch script to run Unity with the Project:

    Here is my code to build the game, making sure that it is within an Editor folder:

    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using System.Linq;
    4. using UnityEditor;
    5.  
    6. public class UnityBuild
    7. {
    8.     private static readonly string GameName = "GameDevIdle";
    9.  
    10.     public static void BuildWindows()
    11.     {
    12.         string[] scenesToBuild = EditorBuildSettings.scenes
    13.             .Where((scene) => scene.enabled == true)
    14.             .Select((scene) => scene.path)
    15.             .ToArray();
    16.  
    17.         string buildsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "_JenkinsBuilds");
    18.         string buildDirectory = Path.Combine(buildsPath, $"{GameName}-Windows-{DateTime.Now.ToString("yyyy-MMM-dd HH-mm-ss")}");
    19.  
    20.         if (Directory.Exists(buildDirectory) == false)
    21.             Directory.CreateDirectory(buildDirectory);
    22.  
    23.         string buildName = $"{GameName}.exe";
    24.  
    25.         BuildPlayerOptions playerOptions = new BuildPlayerOptions()
    26.         {
    27.             scenes = scenesToBuild,
    28.             locationPathName = Path.Combine(buildDirectory, buildName),
    29.             target = BuildTarget.StandaloneWindows64,
    30.             options = BuildOptions.Development
    31.         };
    32.  
    33.         BuildPipeline.BuildPlayer(playerOptions);
    34.     }
    35. }
    36.  
    37.  
    I have tried running this script on my main PC and it works flawlessly, it open Unity (Which is actually visible, unlike on my Jenkins machine) and it immediately starts building and end up giving me an actual Windows exe at the end which works great.

    EDIT:

    To be clear, the issues with my build machine are that:
    1. The Unity editor interface does not open for some reason, I am not running in batch mode, a process does start though in Task Manager including VBCSCompiler so surely it must be doing something.
    2. A final exe is not created at the end of the supposed build process.
    3. I feel like I should mention the Unity read and write permissions error. Jenkins folder is read only. Might be an issue?
     
    Last edited: Mar 16, 2019
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,655
    I would add the -logFile option to send the editor log file to a file that you capture as a Jenkins artifact, then take a look at what it says.
     
  3. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Thats a great idea. I will try and set that up now.
     
  4. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Here we go, luckily that is nice and easy to setup.

    Here is the log:

    https://hastebin.com/purolageka.txt

    We can see the crash here in the log:

    So then as you should, I went to the location mentioned at the bottom of the stack trace and found this, I think it was called Error.txt:

    https://hastebin.com/obozeyamuv.txt

    I also looked at the dump in Visual Studio and it says "The thread tried to read and write to a virtual address for which it does not have appropriate access".
     
  5. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,655
    If you look further up in the log, you can see that the Editor is reporting assertion failures about D3D11 much earlier. It looks like your build machine has an AMD Radeon R5 Graphics chip, but that's an integrated chipset from a few years ago... it officially supports up to D3D12 but it wouldn't surprise me if it struggles a bit. The error code 0x887a0022 means DXGI_ERROR_NOT_CURRENTLY_AVAILABLE.

    It's possible that updating your graphics drivers will help, but alternatively, I would supply the -nographics command line flag, instructing Unity to not attempt to use the GPU.
     
  6. TaleOf4Gamers

    TaleOf4Gamers

    Joined:
    Nov 15, 2013
    Posts:
    825
    Hey,

    I am honestly not sure at what part it started working (Which is both worrying and annoying, but it is more than likely that the nographics command line argument is what fixed it) but it is working now. For future reference in case someone comes across this thread I did a few things including but not limited to:
    • Enabling batchmode and nographics as suggested
    • Changed from using Environment.GetFolderPath to using a hard coded directory for explicitness.
    I am inclined to assume that the nographics fixed it as suggested but I am honestly not sure how that would affect it. The machine can run Unity just fine, albeit a little slower.

    I guess my next step will be storing these build in some online storage, probably Google Drive. Thanks a lot for the assistance superpig. This was actually a lot easier to setup than I expected so thanks for the Unity team for that!