sttz / trimmer

An editor, build and player configuration framework for the Unity game engine.
MIT License
104 stars 8 forks source link

Error: Build profile cloud not be found (Command Line) #9

Open EbiPenMan opened 2 years ago

EbiPenMan commented 2 years ago

Hi I want to build my project from the command line, But I have 2 problems.

  1. On my windows PC run build with command line and got these log:

command: Unity.exe -quit -batchmode -nographics -logFile e:/stdout.log -projectPath "E:\Working_Projects\xTests\unity\livekit\LiveKit\LiveKit" -executeMethod sttz.Trimmer.Editor.BuildManager.Build -profileName Build_Profile_1

Log:

...
Unloading 113 Unused Serialized files (Serialized files now loaded: 0)
Unloading 158 unused Assets / (0.7 MB). Loaded Objects now: 3993.
Memory consumption went from 87.7 MB to 87.0 MB.
Total: 4.958900 ms (FindLiveObjects: 0.362500 ms CreateObjectMapping: 0.307800 ms MarkObjects: 3.922300 ms  DeleteObjects: 0.365100 ms)

Building Build_Profile_1, selected from command line.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Log (object)
sttz.Trimmer.Editor.BuildManager:Build (sttz.Trimmer.Editor.IBuildsCompleteListener) (at Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs:352)
sttz.Trimmer.Editor.BuildManager:Build () (at Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs:310)

(Filename: Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs Line: 352)

Batchmode quit successfully invoked - shutting down!
...
  1. On the Linux server pull the project from git and then:

command: /home/Unity/2021.3.6f1/Editor/Unity -quit -batchmode -nographics -projectPath /home/gitlab-runner/builds/2vyUksym/0/landrocker-workflow/livekit-test -executeMethod sttz.Trimmer.Editor.BuildManager.Build -profileName Build_Profile_1

Log:

...
Application.AssetDatabase Initial Refresh End
Scanning for USB devices : 2.021ms
Initializing Unity extensions:
UpdateMenuTitleForLanguage: 10
[MODES] ModeService[none].Initialize
[MODES] ModeService[none].LoadModes
[MODES] Loading mode Default (0) for mode-current-id-livekit-test
Unloading 5120 Unused Serialized files (Serialized files now loaded: 0)
Unloading 5236 unused Assets / (0.5 MB). Loaded Objects now: 3996.
Memory consumption went from 207.8 MB to 207.3 MB.
Total: 10.478980 ms (FindLiveObjects: 0.918570 ms CreateObjectMapping: 0.590435 ms MarkObjects: 5.236009 ms  DeleteObjects: 3.731601 ms)

Build profile named 'Build_Profile_1' cloud not be found.
UnityEngine.StackTraceUtility:ExtractStackTrace () (at /home/bokken/buildslave/unity/build/Runtime/Export/Scripting/StackTrace.cs:37)
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:LogError (object)
sttz.Trimmer.Editor.BuildManager:Build (sttz.Trimmer.Editor.IBuildsCompleteListener) (at Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs:347)
sttz.Trimmer.Editor.BuildManager:Build () (at Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs:310)

(Filename: Library/PackageCache/ch.sttz.trimmer@5799f29bc7/Editor/BuildManager.cs Line: 347)

Batchmode quit successfully invoked - shutting down!
Setting up 2 worker threads for Enlighten.
AcceleratorClientConnectionCallback - disconnected - :0
Cleanup mono
...

How can I fix these problems on those platforms?

sttz commented 2 years ago

Oh, sorry, I need to update the documentation.

Since 1.3.0 and f19ca220, Trimmer switches the active build target and waits for the domain reload before doing a build. You need to remove the "-quit" or Unity will exit before the domain reload and builds cannot start, Trimmer will quit Unity itself once the builds are complete.

Not sure why the build profile cannot be found on Linux. Trimmer uses the asset database to search for build profiles, maybe there's an issue if the project is imported for the first time?

I also just found an issue where Trimmer will not properly quit Unity in batchmode if the profile cannot be found, will hopefully fix that soon.

EbiPenMan commented 2 years ago

@sttz Thanks for your reply.

My problem for build on the Windows platform was fixed by removing '-quit' and the project compiled correctly.

But on the Linux platform, I still have the same problem as before and it doesn't find the build profile.

As you said yourself After removing Argument '-quit' on the Linux platform, Unity did not close. Because the build process encountered an error and did not find the build profile.

EbiPenMan commented 2 years ago

@sttz Hi Is there a way to temporarily solve the problem of not finding the build profile in Linux? For example, the address is hard-coded.

Because I really need this.

sttz commented 2 years ago

Could you try importing the project once first and then running the build in a separate invocation? Just to see if the issue is related to the project being imported for the first time (i.e. running Unity once without -executeMethod and then again with).

As a workaround, you could write your own method that loads the profile with a path, e.g.

using System;
using sttz.Trimmer.Editor;
using UnityEditor;
using UnityEngine;

public class CustomBuild
{
    const string PROFILE_PATH = "Assets/My_Build_Profile.asset";

    public static void Build()
    {
        var profile = AssetDatabase.LoadAssetAtPath<BuildProfile>(PROFILE_PATH);
        if (profile == null) {
            throw new Exception($"Build Profile not found at path: {PROFILE_PATH}");
        }

        var onComplete = ScriptableObject.CreateInstance<BuildManager.CommandLineBuildsCompleteListener>();
        BuildManager.Build(profile, onComplete);
    }
}
EbiPenMan commented 2 years ago

Ok, I will definitely do this and let you know the result. Thank you for your follow up