[SOLVED] Can not build client over CLI

hello,

i wanted to setup a cli based building system, but sadly i get an error which makes no sense and i hope someone here can help me.

the command i execute is the following:

/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -projectPath "${WORKSPACE}" -executeMethod BuildCommand.BuildiOS -quit -logFile /dev/stdout

the error i get is the following:

Project has invalid dependencies:
com.unity.modules.androidjni: no such package available : com.unity.modules.androidjni
com.unity.ugui: no such package available : com.unity.ugui```

funny tho in the Unity IDE itself it works flawless. :/ 
i have looked trough several of the issue topics here but no solution helped me so far.....

I hope someone can help me.

Hi @Gardosen ,

I’m surprised that this isn’t working. Can you specify what Unity version you are using? You seemed to have installed the Editor without using the Hub, correct? And lastly, could you please create a Bug Report and attach the generated Editor.log so we can inspect it?

hy @maximeb_unity ,

here are some details:

  • i have installed 2020.2.1f1 over the Unity_Hub, it is the only version i currently have installed
  • Unity Hub version is Version 2.4.2 (2.4.2)
  • i am running macos big sure 11.1 on a 2019 macbook pro 16 inch
  • i am using a custom script i found in the forum and which i modified a bit so far to serve my need better. i will attach it here
  • if i execute the commands over the Unity IDE everything works fine and the clients are build.
    – ios can be compiled to an xcode project to be installed on an ipad
    – macos can be compiled
    – android can be compiled

i have checked the Unity Log folder but if i clear everything, the only log which is recreated when i execute my cli command is the upm.log

Edit 1: i have tested now if this is reproducable and actually it is.
Step 1: Create a new 3D Project
Step 2: Copy the BuildCommand.cs to the Editor folder under Assets so it gets loaded by Unity
Step 3: Close unity and open a terminal
Step 4: execute the command from below

Expected Behaviour: The client should build fine
Actual Behaviour: The Package Manager returns an error related to the ugui and androidjndi package which can not be resolved

cli command

/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -projectPath “${WORKSPACE}” -executeMethod BuildCommand.BuildiOS -quit -logFile -v /dev/stdout

terminal log

Loading GUID ↔ Path mappings…0.000047 seconds
Loading Asset Database…0.012246 seconds
Audio: FMOD Profiler initialized on port 54900
AssetDatabase consistency checks…Rebuilding GUID cache … 0.005254 seconds.
0.043577 seconds
Refreshing native plugins compatible for Editor in 22.10 ms, found 1 plugins.
Preloading 0 native plugins for Editor in 0.00 ms.
DisplayProgressbar: Unity Package Manager
[Package Manager] Done resolving packages in 1.13s seconds
[Package Manager] An error occurred while resolving packages:
Project has invalid dependencies:
com.unity.2d.sprite: no such package available : com.unity.2d.sprite
com.unity.2d.tilemap: no such package available : com.unity.2d.tilemap
com.unity.modules.androidjni: no such package available : com.unity.modules.androidjni
com.unity.ugui: no such package available : com.unity.ugui
A re-import of the project may be required to fix the issue or a manual modification of /Users/marco/Projects/XXXX/XXXX/Packages/manifest.json file.
[Package Manager] Server::Kill – Server was shutdown

upm.log

{“level”:“info”,“message”:“Starting Server”,“timestamp”:“2021-01-19T22:01:37.015Z”}
{“level”:“info”,“message”:“Health Request received”,“timestamp”:“2021-01-19T22:01:37.119Z”}
{“level”:“warn”,“message”:“Package folder [/Applications/Unity/Unity.app/Contents/Resources/PackageManager/Editor/Packman_Temp] missing package manifest.”,“timestamp”:“2021-01-19T22:01:37.233Z”}

the editor plugin which i am using and which i refed via “-executeMethod BuildCommand.BuildiOS”

using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEditor;

public class BuildCommand : MonoBehaviour
{
    private const string ANDROID_KEYSTORE_PASS = "";
    private const string ANDROID_KEYALIAS_NAME = "";
    private const string ANDROID_KEYALIAS_PASS = "";

    private static readonly BuildTarget[] TargetToBuildAll =
    {
        BuildTarget.Android,
        BuildTarget.iOS,
        BuildTarget.StandaloneWindows,
        BuildTarget.StandaloneWindows64,
        BuildTarget.StandaloneOSX
  
    };

    public static string ProductName => PlayerSettings.productName;

    private static string BuildPathRoot
    {
        get
        {
            string path = $"{Application.dataPath}/../ClientBuilds/";
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);
            return path;
        }
    }

    private static int AndroidLastBuildVersionCode
    {
        get => PlayerPrefs.GetInt("LastVersionCode", -1);
        set => PlayerPrefs.SetInt("LastVersionCode", value);
    }

    private static BuildTargetGroup ConvertBuildTarget(BuildTarget buildTarget)
    {
        switch (buildTarget)
        {
            case BuildTarget.StandaloneOSX:
                return BuildTargetGroup.Standalone;
            case BuildTarget.iOS:
                return BuildTargetGroup.iOS;
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
            case BuildTarget.StandaloneLinux64:
            case BuildTarget.Android:
                return BuildTargetGroup.Android;
            default:
                return BuildTargetGroup.Standalone;
        }
    }

    private static string GetExtension(BuildTarget buildTarget)
    {
        switch (buildTarget)
        {
            case BuildTarget.StandaloneOSX:
                return ".app";
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
                return ".exe";
            case BuildTarget.iOS:
                return "";
            case BuildTarget.Android:
                return ".apk";
            case BuildTarget.StandaloneLinux64:
                break;
        }

        return ".unknown";
    }

    private static BuildPlayerOptions GetDefaultPlayerOptions()
    {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();

        List<string> listScenes = new List<string>();
        foreach (var s in EditorBuildSettings.scenes)
        {
            if (s.enabled)
                listScenes.Add(s.path);
        }

        buildPlayerOptions.scenes = listScenes.ToArray();
        buildPlayerOptions.options = BuildOptions.None;
  
        return buildPlayerOptions;
    }

    private static void DefaultBuild(BuildTarget buildTarget)
    {
        BuildTargetGroup targetGroup = ConvertBuildTarget(buildTarget);
        string targetFolder = GetFolderByBuildTarget(buildTarget);
  
        string path = $"{BuildPathRoot}{targetFolder}";
  
        string name = ProductName + GetExtension(buildTarget);
  
        string defineSymbole = PlayerSettings.GetScriptingDefineSymbolsForGroup(targetGroup);
  
        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole + ";BUILD");

        PlayerSettings.Android.keystorePass = ANDROID_KEYSTORE_PASS;
        PlayerSettings.Android.keyaliasName = ANDROID_KEYALIAS_NAME;
        PlayerSettings.Android.keyaliasPass = ANDROID_KEYALIAS_PASS;

        BuildPlayerOptions buildPlayerOptions = GetDefaultPlayerOptions();

        buildPlayerOptions.locationPathName = Path.Combine(path, name);
        buildPlayerOptions.target = buildTarget;

        EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, buildTarget);

        string result = buildPlayerOptions.locationPathName + ": " + BuildPipeline.BuildPlayer(buildPlayerOptions);
        Debug.Log(result);
        PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, defineSymbole);

        if (buildTarget == BuildTarget.Android)
            AndroidLastBuildVersionCode = PlayerSettings.Android.bundleVersionCode;

        EditorUtility.RevealInFinder(path);
    }

    private static string GetFolderByBuildTarget(BuildTarget _buildTarget)
    {
        switch (_buildTarget)
        {
            case BuildTarget.Android:
                return "Android";
            case BuildTarget.iOS:
                return "iOS";
            case BuildTarget.StandaloneWindows:
            case BuildTarget.StandaloneWindows64:
                return "Windows";
            case BuildTarget.StandaloneOSX:
                return "MacOS";
            default:
                return "garbage"; //should never happen for anything supported
        }
    }

    [MenuItem("Build/Single/Build Android")]
    private static void BuildAndroid()
    {
        DefaultBuild(BuildTarget.Android);
    }

    [MenuItem("Build/Single/Build Win32")]
    private static void BuildWin32()
    {
        DefaultBuild(BuildTarget.StandaloneWindows);
    }

    [MenuItem("Build/Single/Build Win64")]
    private static void BuildWin64()
    {
        DefaultBuild(BuildTarget.StandaloneWindows64);
    }

    [MenuItem("Build/Single/Build iOS")]
    private static void BuildiOS()
    {
        DefaultBuild(BuildTarget.iOS);
    }

    [MenuItem("Build/Single/Build MacOS")]
    private static void BuildMacOS()
    {
        DefaultBuild(BuildTarget.StandaloneOSX);
    }

    [MenuItem("Build/Get Build Number")]
    private static void BuildNumber()
    {
        Debug.Log("Current/Last: " + PlayerSettings.Android.bundleVersionCode + "/" + AndroidLastBuildVersionCode);
    }

    [MenuItem("Build/Build Number/Up Build Number")]
    private static void BuildNumberUp()
    {
        PlayerSettings.Android.bundleVersionCode++;
        BuildNumber();
    }

    [MenuItem("Build/Build Number/Down Build Number")]
    private static void BuildNumberDown()
    {
        PlayerSettings.Android.bundleVersionCode--;
        BuildNumber();
    }

    [MenuItem("Build/Build All")]
    private static void BuildAll()
    {
        foreach (BuildTarget b in TargetToBuildAll)
        {
            DefaultBuild(b);
        }
    }
}

@maximeb_unity

after a night of sleep i took this again into my hands and checked the fact that you for some reason assumed i do not have installed Unity over the hub. I was abit confused that the path of Unity was not part of the Hub folder under Unity and wiped EVERYTHING away from my macbook related to Unity.

apparently you were right even tho i do not get how this is even possible as i always had used Unity with the hub since i can think of.
but based on the things i found, apparently i had a super weird screwup version of unity running which was “apparently” installed by the Hub, into the existing installation directly with a mixup of the 2018 package manager + unity 2020.2.1f1 + temp files of extremly old textmesh packages which in the editor appeared to be as 3.0.3 but where 2.x.x (this might also explain some issues i had with my project recently.

now i am able to build with the client just fine.
Problem solved o.o

1 Like

Hey, thanks for letting us know things are fine on your end! :slight_smile: