Unity-Technologies/UnityCsReference · error · ArgumentException
Active build profile is null.
Error message
Active build profile is null.
What it means
Thrown by GetBuildPlayerOptionsFromActiveProfile when BuildProfile.GetActiveBuildProfile() returns null. Building requires an active profile to derive buildTarget, subtarget, and options, so a null active profile is a hard stop expressed as ArgumentException. The error message is terse because the root cause is configuration, not a code defect in the caller.
Source
Thrown at Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs:508
public static void CallInternalBuildMethods(bool askForBuildLocation, BuildOptions options)
{
BuildPlayerWindow.CallBuildMethods(askForBuildLocation, options);
}
/// <summary>
/// Construct the build player options from the active build profile.
/// </summary>
/// <param name="buildLocation">The path where the application will be built.</param>
/// <param name="assetBundleManifestPath">The path to the asset bundle manifest file.</param>
/// <param name="customBuildOptions">Custom build options to be applied.</param>
/// <see cref="BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptionsInternal"/>
internal static BuildPlayerOptions GetBuildPlayerOptionsFromActiveProfile(string buildLocation, string assetBundleManifestPath, BuildOptions customBuildOptions, string[] extraScriptingDefines = null)
{
var options = new BuildPlayerOptions();
var activeProfile = BuildProfile.GetActiveBuildProfile();
if (activeProfile == null)
throw new ArgumentException("Active build profile is null.");
var buildTarget = activeProfile.buildTarget;
var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);
int subtarget = IsStandalonePlatform(buildTarget) ?
(int)activeProfile.subtarget : EditorUserBuildSettings.GetActiveSubtargetFor(buildTarget);
var buildPath = !string.IsNullOrEmpty(buildLocation) ?
buildLocation : activeProfile.GetComponent<BuildDestinationSettings>()?.buildPath ?? string.Empty;
options.options = GetBuildOptions(buildTarget, buildTargetGroup, buildPath, customBuildOptions);
options.target = buildTarget;
options.subtarget = subtarget;
options.targetGroup = buildTargetGroup;
options.locationPathName = buildPath;
options.assetBundleManifestPath = assetBundleManifestPath ?? PostprocessBuildPlayer.GetStreamingAssetsBundleManifestPath();
options.scenes = EditorBuildSettingsScene.GetActiveSceneList(activeProfile.GetScenesForBuild());
options.previousBuildReportDirectories = PostprocessBuildPlayer.GetPreviousContentBuildReportDirectories();
options.extraScriptingDefines = extraScriptingDefines;View on GitHub (pinned to 225b0fbdb5)
Solutions
- Select and activate a build profile in the Build Profiles window before building.
- In code, verify BuildProfile.GetActiveBuildProfile() is non-null before triggering a build.
- If the active profile was deleted, create/select a new profile and set it active.
Example fix
// before
var opts = BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(loc, manifest, options);
// after
if (BuildProfile.GetActiveBuildProfile() == null)
throw new InvalidOperationException("No active build profile. Select one first.");
var opts = BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(loc, manifest, options); Defensive patterns
Strategy: validation
Validate before calling
if (BuildProfile.GetActiveBuildProfile() == null) throw new InvalidOperationException("No active build profile selected."); Type guard
static bool HasActiveProfile() => BuildProfile.GetActiveBuildProfile() != null;
Prevention
- Verify an active profile exists before building.
- Set a default profile during project setup/CI.
- Re-select an active profile if the previous one was deleted.
When it happens
Trigger: Invoking a build pipeline path that calls GetBuildPlayerOptionsFromActiveProfile when no build profile is currently active (GetActiveBuildProfile returns null).
Common situations: Fresh project where no profile has been activated; the active profile asset was deleted or moved; a script changed the active profile to null; project settings reset; running build automation before a profile is selected.
Related errors
- The component {typeof(T).Name} already exists in the build p
- Type {type.Name} is not a ScriptableObject or a supported se
- The object to add cannot be null.
- The component {typeof(T).Name} is required and cannot be rem
- The object to remove cannot be null.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/14052c0140705938.
Report an issue: GitHub.