{"record":{"id":"14052c0140705938","repo":"Unity-Technologies/UnityCsReference","slug":"active-build-profile-is-null","errorCode":null,"errorMessage":"Active build profile is null.","messagePattern":"Active build profile is null\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs","lineNumber":508,"sourceCode":"        public static void CallInternalBuildMethods(bool askForBuildLocation, BuildOptions options)\n        {\n            BuildPlayerWindow.CallBuildMethods(askForBuildLocation, options);\n        }\n\n        /// <summary>\n        /// Construct the build player options from the active build profile.\n        /// </summary>\n        /// <param name=\"buildLocation\">The path where the application will be built.</param>\n        /// <param name=\"assetBundleManifestPath\">The path to the asset bundle manifest file.</param>\n        /// <param name=\"customBuildOptions\">Custom build options to be applied.</param>\n        /// <see cref=\"BuildPlayerWindow.DefaultBuildMethods.GetBuildPlayerOptionsInternal\"/>\n        internal static BuildPlayerOptions GetBuildPlayerOptionsFromActiveProfile(string buildLocation, string assetBundleManifestPath, BuildOptions customBuildOptions, string[] extraScriptingDefines = null)\n        {\n            var options = new BuildPlayerOptions();\n            var activeProfile = BuildProfile.GetActiveBuildProfile();\n\n            if (activeProfile == null)\n                throw new ArgumentException(\"Active build profile is null.\");\n\n            var buildTarget = activeProfile.buildTarget;\n            var buildTargetGroup = BuildPipeline.GetBuildTargetGroup(buildTarget);\n            int subtarget = IsStandalonePlatform(buildTarget) ?\n                (int)activeProfile.subtarget : EditorUserBuildSettings.GetActiveSubtargetFor(buildTarget);\n\n            var buildPath = !string.IsNullOrEmpty(buildLocation) ?\n                buildLocation : activeProfile.GetComponent<BuildDestinationSettings>()?.buildPath ?? string.Empty;\n\n            options.options = GetBuildOptions(buildTarget, buildTargetGroup, buildPath, customBuildOptions);\n            options.target = buildTarget;\n            options.subtarget = subtarget;\n            options.targetGroup = buildTargetGroup;\n            options.locationPathName = buildPath;\n            options.assetBundleManifestPath = assetBundleManifestPath ?? PostprocessBuildPlayer.GetStreamingAssetsBundleManifestPath();\n            options.scenes = EditorBuildSettingsScene.GetActiveSceneList(activeProfile.GetScenesForBuild());\n            options.previousBuildReportDirectories = PostprocessBuildPlayer.GetPreviousContentBuildReportDirectories();\n            options.extraScriptingDefines = extraScriptingDefines;","sourceCodeStart":490,"sourceCodeEnd":526,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildProfile/BuildProfileModuleUtil.cs#L490-L526","documentation":"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.","triggerScenarios":"Invoking a build pipeline path that calls GetBuildPlayerOptionsFromActiveProfile when no build profile is currently active (GetActiveBuildProfile returns null).","commonSituations":"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.","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."],"exampleFix":"// before\nvar opts = BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(loc, manifest, options);\n\n// after\nif (BuildProfile.GetActiveBuildProfile() == null)\n    throw new InvalidOperationException(\"No active build profile. Select one first.\");\nvar opts = BuildProfileModuleUtil.GetBuildPlayerOptionsFromActiveProfile(loc, manifest, options);","handlingStrategy":"validation","validationCode":"if (BuildProfile.GetActiveBuildProfile() == null) throw new InvalidOperationException(\"No active build profile selected.\");","typeGuard":"static bool HasActiveProfile() => BuildProfile.GetActiveBuildProfile() != null;","tryCatchPattern":null,"preventionTips":["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."],"tags":["unity","buildprofile","active-profile","null","build","argumentexception"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}