Specify build output path (via command line or edit project settings files)

Hi,
I am doing build automation for our unity projects, one step is to specify the unity build output path with batch mode/command line, instead of choosing the output folder when building from editor.
I have checked this page Unity - Manual: Command-line arguments, but can not find an argument for output path.
I’ve also read through several files, like BuildSettings.asset, EditorUserBuildSettings.asset ProjectSettings.asset under \Library folder, and the .asset files under \ProjectSettings folder, still couldn’t find any code that can assign the output path.

I don’t think Unity took all the efforts to create a usable batch mode, but does not give us the liberty to specify output path. Am I missing something here?

+1 this question. A path can be specified when using -buildWindows64Player but not -buildTarget

Did anyone find an answer for this? I also need to define an output for buildTarget.

Hello,
You can use the IPreprocessBuildWithReport in an editor class to get a build summary which in turn has the path. I’m attempting to modify that now, if something comes up I’ll update.

The build report doesn’t return the full path for me. It returns the parent path. The outputPath in the report is read only clearly as it’s a summary.

The only way to go about doings is by running a BuildPlayer with the BuildPipeline https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildPlayer.html

I couldn’t find it either so I ended up writing a utility function to do this. I’m sure I’m missing something, too.

    private static string GetOutputPath()
    {
        var args = Environment.GetCommandLineArgs().ToList();
        var outputPathIndex = args.IndexOf("-outputPath");
        if (outputPathIndex == -1)
        {
            throw new Exception("-outputPath parameter missing on CLI");
        }
        return args[outputPathIndex + 1];
    }