Unity-Technologies/UnityCsReference · error · ArgumentException
BuildContentDirectoryParameters.outputPath cannot be empty
Error message
BuildContentDirectoryParameters.outputPath cannot be empty
What it means
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.
Source
Thrown at Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs:469
{
if (buildParameters.targetPlatform == 0 || buildParameters.targetPlatform == BuildTarget.NoTarget)
{
buildParameters.targetPlatform = EditorUserBuildSettings.activeBuildTarget;
// Note: subtarget is associated with multiple enums, and 0 may have a specific meaning,
// so we only auto-set it when the target is also coming from the build settings
buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);
}
// For Standalone platforms, the Default subtarget means to use the current active one
if (GetBuildTargetGroup(buildParameters.targetPlatform) == BuildTargetGroup.Standalone &&
(StandaloneBuildSubtarget)buildParameters.subtarget == StandaloneBuildSubtarget.Default)
{
buildParameters.subtarget = EditorUserBuildSettings.GetActiveSubtargetFor(buildParameters.targetPlatform);
}
if (string.IsNullOrEmpty(buildParameters.outputPath))
throw new ArgumentException("BuildContentDirectoryParameters.outputPath cannot be empty");
if (!Directory.Exists(buildParameters.outputPath))
{
// Attempt an on the fly creation of the directory.
try
{
Directory.CreateDirectory(buildParameters.outputPath);
}
catch (System.Exception ex)
{
Debug.LogError($"BuildContentDirectory failed. The output path '{buildParameters.outputPath}' does not exist and cannot be created.");
// Pass up the specific exception so that the cause (permissions, invalid filename etc) is not swallowed.
throw ex;
}
}
buildParameters.outputPath = buildParameters.outputPath.Replace('\\', '/');
View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
var parameters = new BuildContentDirectoryParameters
{
// outputPath omitted
};
BuildPipeline.BuildContentDirectory(parameters);
// after
var parameters = new BuildContentDirectoryParameters
{
outputPath = "Build/Content"
};
BuildPipeline.BuildContentDirectory(parameters); Defensive patterns
Strategy: validation
Validate before calling
void ValidateBuildContentParameters(BuildContentDirectoryParameters p)
{
if (string.IsNullOrEmpty(p.outputPath))
throw new ArgumentException(
"BuildContentDirectoryParameters.outputPath must be set to a valid directory.");
}
// Before BuildContentDirectory:
ValidateBuildContentParameters(parameters); Prevention
- 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.
When it happens
Trigger: Calling BuildPipeline.BuildContentDirectory with a BuildContentDirectoryParameters object whose outputPath field was never assigned, assigned null, or assigned an empty string.
Common situations: 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.
Related errors
- Scene path "{0}" contains invalid directory separators.
- Invalid build path: '{buildPlayerOptions.locationPathName}'.
- The output path "{buildParameters.outputPath}" doesn't exist
- The build target does not support build appending.
- The build cannot be appended.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/86ec834a59aa7d8e.
Report an issue: GitHub.