-
-
Notifications
You must be signed in to change notification settings - Fork 9
Starting a BuildTask without UI
James edited this page Dec 5, 2025
·
3 revisions
Want to start uploading without the UI?
You can make your own UploadTask, define what the sources, modifiers and destinations are and fire it mostly-async.
Example below to copy+paste into your project
using System.Text;
using UnityEditor;
using UnityEngine;
using Wireframe;
/// <summary>
/// Example of
/// - Start a new build using an existing build config from the project settings
/// - Modifying the build that was created
/// - Uploading it to the internal branch on Steam
/// - Getting the report of the process with its logs
/// </summary>
public static class TestUploadTask
{
[MenuItem("Test/TestBuildTask")]
public static void Test()
{
UploadConfig uploadConfig = new UploadConfig("TestUploadTask");
//
// SOURCES
//
// These are what files will be uploaded
// This example has 1 source
// - This will try and find a build config from project settings with the given name
BuildConfig buildConfig = BuildConfig.FromBuildName("Debugging Build");
uploadConfig.AddSource(new UploadConfig.SourceData()
{
Source = new BuildConfigSource(buildConfig) // The source to use for this config.
});
//
// MODIFIERS
//
// These modify the files from 'sources' after they have been copied to a temporary folder (aka: cache)
// This example has 2 modifiers
// - Ignore all files in folders named 'DoNotShip' (These are always included in builds using Mono)
// - Ignore all files with 'ButDontShipItWithYourGame' in the filename (These are always included in builds using IL2CPP)
var doNotShipFiles = new ExcludeFoldersModifier(".*DoNotShip", recursive:true, searchAllDirectories:false);
uploadConfig.AddModifier(new UploadConfig.ModifierData(doNotShipFiles));
var dontShipFiles = new ExcludeFilesModifier(".*ButDontShipItWithYourGame", recursive:true, searchAllDirectories:false);
uploadConfig.AddModifier(new UploadConfig.ModifierData(dontShipFiles));
//
// DESTINATIONS
//
// These are where the files will be uploaded to
// This example has 2 destinations
// - Copy the build to the projects/Builds folder
// - Upload the build to Steam on the internal branch
uploadConfig.AddDestination(new UploadConfig.DestinationData()
{
Enabled = true, // When true this destination will be used in the upload.
Destination = new LocalPathDestination(localPath:"{projectPath}/Builds") // Copy the files to the Builds folder in the project.
});
SteamUploadDestination steamDestination = new SteamUploadDestination();
steamDestination.SetSteamApp(123456789); // Replace it with your actual Steam App ID
steamDestination.AddSteamDepot(10000); // Replace it with your actual Steam Depot ID
steamDestination.SetSteamBranch("internal"); // Upload to a branch named 'internal'
uploadConfig.AddDestination(new UploadConfig.DestinationData()
{
Enabled = true, // When true, this destination will be used in the upload.
Destination = steamDestination // Upload to Steam
});
//
// Start the upload
//
// Set up the task
UploadTask uploadTask = new UploadTask();
uploadTask.AddConfig(uploadConfig);
uploadTask.SetBuildDescription("#{buildVersion} v{version} - This was uploaded via C# and not the GUI.");
uploadTask.OnComplete += (report)=>
{
StringBuilder log = new StringBuilder();
if (report.Successful)
{
log.AppendLine("Build Task Completed Successfully");
}
else
{
log.AppendLine("Build Task Failed");
foreach ((AUploadTask_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 (report.Successful)
{
Debug.Log(log.ToString());
}
else
{
Debug.LogError(log.ToString());
}
};
// Start the task
uploadTask.Start(invokeDebugLogs:false);
}
}