Unity-Technologies/UnityCsReference · error · ArgumentException
Non-development build cannot allow debugging. Either add the
Error message
Non-development build cannot allow debugging. Either add the Development build option, or remove the AllowDebugging build option.
What it means
Thrown when BuildPlayer is called with BuildOptions.AllowDebugging set but BuildOptions.Development is NOT set. Script debugging attaches a debugger to the running player, which requires the Development build pipeline that includes debugging symbols and the debug transport.
Source
Thrown at Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs:234
{
CanAppendBuild canAppend = BuildCanBeAppended(buildPlayerOptions.target, buildPlayerOptions.locationPathName);
if (canAppend == CanAppendBuild.Unsupported)
throw new InvalidOperationException("The build target does not support build appending.");
if (canAppend == CanAppendBuild.No)
throw new InvalidOperationException("The build cannot be appended.");
}
if (buildPlayerOptions.scenes != null)
{
for (int i = 0; i < buildPlayerOptions.scenes.Length; i++)
buildPlayerOptions.scenes[i] = buildPlayerOptions.scenes[i].Replace('\\', '/').Replace("//", "/");
}
if ((buildPlayerOptions.options & BuildOptions.Development) == 0)
{
if ((buildPlayerOptions.options & BuildOptions.AllowDebugging) != 0)
{
throw new ArgumentException("Non-development build cannot allow debugging. Either add the Development build option, or remove the AllowDebugging build option.");
}
if ((buildPlayerOptions.options & BuildOptions.EnableCodeCoverage) != 0)
{
throw new ArgumentException("Non-development build cannot allow code coverage. Either add the Development build option, or remove the EnableCodeCoverage build option.");
}
if ((buildPlayerOptions.options & BuildOptions.EnableDeepProfilingSupport) != 0)
{
throw new ArgumentException("Non-development build cannot allow deep profiling support. Either add the Development build option, or remove the EnableDeepProfilingSupport build option.");
}
if ((buildPlayerOptions.options & BuildOptions.ConnectWithProfiler) != 0)
{
throw new ArgumentException("Non-development build cannot allow auto-connecting the profiler. Either add the Development build option, or remove the ConnectWithProfiler build option.");
}
}
elseView on GitHub (pinned to 225b0fbdb5)
Solutions
- Add BuildOptions.Development to the options bitmask when AllowDebugging is required.
- Remove BuildOptions.AllowDebugging from the options bitmask if this is intended to be a release build.
- Create a helper that automatically sets Development when any development-only flag (AllowDebugging, EnableCodeCoverage, EnableDeepProfilingSupport, ConnectWithProfiler) is present.
Example fix
// before
var options = new BuildPlayerOptions
{
options = BuildOptions.AllowDebugging,
target = BuildTarget.StandaloneWindows64
};
BuildPipeline.BuildPlayer(options);
// after
var options = new BuildPlayerOptions
{
options = BuildOptions.Development | BuildOptions.AllowDebugging,
target = BuildTarget.StandaloneWindows64
};
BuildPipeline.BuildPlayer(options); Defensive patterns
Strategy: validation
Validate before calling
BuildOptions EnsureDevelopmentForDevOnlyFlags(BuildOptions options)
{
BuildOptions devOnlyFlags = BuildOptions.AllowDebugging |
BuildOptions.EnableCodeCoverage |
BuildOptions.EnableDeepProfilingSupport |
BuildOptions.ConnectWithProfiler;
if ((options & devOnlyFlags) != 0 && (options & BuildOptions.Development) == 0)
options |= BuildOptions.Development;
return options;
}
// Before BuildPlayer:
options.options = EnsureDevelopmentForDevOnlyFlags(options.options); Prevention
- Create a helper that auto-adds BuildOptions.Development when any development-only flag is present.
- Never set AllowDebugging, EnableCodeCoverage, EnableDeepProfilingSupport, or ConnectWithProfiler without also setting Development.
- Centralize BuildOptions construction in a single factory method per build configuration.
When it happens
Trigger: Calling BuildPipeline.BuildPlayer with a BuildOptions combination that includes AllowDebugging but does not include Development — e.g., options = BuildOptions.AllowDebugging or options = BuildOptions.AllowDebugging | BuildOptions.CompressWithLz4.
Common situations: A build script toggles individual debug flags without ensuring Development is set, or a release-oriented build pipeline accidentally inherits a debugging option from shared configuration. Also happens when copying BuildOptions from a development preset into a release build.
Related errors
- Non-development build cannot allow code coverage. Either add
- Non-development build cannot allow deep profiling support. E
- Non-development build cannot allow auto-connecting the profi
- Code coverage is unavailable for the selected build target.
- Scene path "{0}" contains invalid directory separators.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/bb97ca1af7527c15.
Report an issue: GitHub.