Skip to content

Starting a BuildTask without UI

James Veugelaers edited this page May 6, 2025 · 4 revisions

Want to start a build without the UI?

You can make your own BuildTask, define what the sources, modifiers and destinations are and firing it async.

Example below

using System.Text;
using UnityEditor;
using UnityEngine;
using Wireframe;

public static class TestBuildTest
{
    [MenuItem("Test/Start BuildTask")]
    public static void Upload()
    {
        // This is a test build task
        Debug.Log("Beginning BuildTask");

        // Create Build Config that
        // 1. Uses a folder off your local pc
        // 2. Removes any DoNotShip folders and their contents
        // 3. Uploads to Steam with the given AppID and DepotID
        BuildConfig buildConfig = new BuildConfig("TestBuildTask");
        buildConfig.AddSource(new BuildConfig.SourceData()
        {
            Source = new FolderSource("PathToABuildGameProject")
        });
        buildConfig.AddDestination(new BuildConfig.DestinationData()
        {
            Destination = new SteamUploadDestination(123456780, 123456781, "default")
        });

        buildConfig.AddModifier(new BuildConfig.ModifierData(new ExcludeFoldersModifier("*DoNotShip*", true, true)));
        buildConfig.AddModifier(new BuildConfig.ModifierData(new SteamDRM_BuildModifier(123456780)));


        // Set up a BuildTask so it's ready to upload
        BuildTask buildTask = new BuildTask();
        buildTask.AddConfig(buildConfig);
        buildTask.SetBuildDescription("Test Build Task");

        // Begin the BuildTask and when its done log out the results
        BuildTaskReport report = new BuildTaskReport(buildConfig.GUID, false);
        buildTask.Start(report, onComplete: (successful) =>
        {
            StringBuilder log = new StringBuilder();
            if (successful)
            {
                log.AppendLine("Build Task Completed Successfully");
            }
            else
            {
                log.AppendLine("Build Task Failed");
                foreach ((ABuildTask_Step.StepType Key, string FailReason) reason in report.GetFailReasons())
                {
                    log.AppendLine($"[{reason.Key}] {reason.FailReason}");
                }
            }

            log.AppendLine("Build Task Report:");
            log.AppendLine(report.GetReport());

            if (successful)
            {
                Debug.Log(log.ToString());
            }
            else
            {
                Debug.LogError(log.ToString());
            }
        });
    }
}

Clone this wiki locally