{"record":{"id":"86ec834a59aa7d8e","repo":"Unity-Technologies/UnityCsReference","slug":"buildcontentdirectoryparameters-outputpath-cannot","errorCode":null,"errorMessage":"BuildContentDirectoryParameters.outputPath cannot be empty","messagePattern":"BuildContentDirectoryParameters\\.outputPath cannot be empty","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs","lineNumber":469,"sourceCode":"        {\n            if (buildParameters.targetPlatform == 0 || buildParameters.targetPlatform == BuildTarget.NoTarget)\n            {\n                buildParameters.targetPlatform = EditorUserBuildSettings.activeBuildTarget;\n\n                // Note: subtarget is associated with multiple enums, and 0 may have a specific meaning,\n                // so we only auto-set it when the target is also coming from the build settings\n                buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);\n            }\n\n            // For Standalone platforms, the Default subtarget means to use the current active one\n            if (GetBuildTargetGroup(buildParameters.targetPlatform) == BuildTargetGroup.Standalone &&\n                (StandaloneBuildSubtarget)buildParameters.subtarget == StandaloneBuildSubtarget.Default)\n            {\n                buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);\n            }\n\n            if (string.IsNullOrEmpty(buildParameters.outputPath))\n                throw new ArgumentException(\"BuildContentDirectoryParameters.outputPath cannot be empty\");\n\n            if (!Directory.Exists(buildParameters.outputPath))\n            {\n                // Attempt an on the fly creation of the directory.\n                try\n                {\n                    Directory.CreateDirectory(buildParameters.outputPath);\n                }\n                catch (System.Exception ex)\n                {\n                    Debug.LogError($\"BuildContentDirectory failed. The output path '{buildParameters.outputPath}' does not exist and cannot be created.\");\n                    // Pass up the specific exception so that the cause (permissions, invalid filename etc) is not swallowed.\n                    throw ex;\n                }\n            }\n\n            buildParameters.outputPath = buildParameters.outputPath.Replace('\\\\', '/');\n","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs#L451-L487","documentation":"Thrown by BuildContentDirectory when the BuildContentDirectoryParameters.outputPath is null or empty. The content build pipeline (used by the Scriptable Build Pipeline / SBP) requires a valid output directory to write built content artifacts.","triggerScenarios":"Calling BuildPipeline.BuildContentDirectory with a BuildContentDirectoryParameters object whose outputPath field was never assigned, assigned null, or assigned an empty string.","commonSituations":"Constructing BuildContentDirectoryParameters without initializing outputPath, reading outputPath from a config file that is missing the field, or refactoring code that previously used a different parameter name.","solutions":["Set buildParameters.outputPath to a valid absolute or relative directory path before calling BuildContentDirectory.","Verify the config source that supplies outputPath is present and non-empty.","Add a pre-call null/empty check with a clear error message pointing to the configuration source."],"exampleFix":"// before\nvar parameters = new BuildContentDirectoryParameters\n{\n    // outputPath omitted\n};\nBuildPipeline.BuildContentDirectory(parameters);\n\n// after\nvar parameters = new BuildContentDirectoryParameters\n{\n    outputPath = \"Build/Content\"\n};\nBuildPipeline.BuildContentDirectory(parameters);","handlingStrategy":"validation","validationCode":"void ValidateBuildContentParameters(BuildContentDirectoryParameters p)\n{\n    if (string.IsNullOrEmpty(p.outputPath))\n        throw new ArgumentException(\n            \"BuildContentDirectoryParameters.outputPath must be set to a valid directory.\");\n}\n\n// Before BuildContentDirectory:\nValidateBuildContentParameters(parameters);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always initialize outputPath when constructing BuildContentDirectoryParameters.","Read outputPath from a validated configuration source with a fallback default.","Add a pre-call assertion in debug builds to catch missing outputPath early."],"tags":["unity","build-pipeline","content-build","path-validation","scriptable-build-pipeline"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}