Unity-Technologies/UnityCsReference · error · ArgumentException

Non-development build cannot allow deep profiling support. E

Error message

Non-development build cannot allow deep profiling support. Either add the Development build option, or remove the EnableDeepProfilingSupport build option.

What it means

Thrown when BuildPlayer is called with BuildOptions.EnableDeepProfilingSupport set but BuildOptions.Development is NOT set. Deep profiling instruments every method call at the IL level, which is only available through the Development build pipeline.

Source

Thrown at Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs:244

                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.");
                }
            }
            else
            {
                if ((buildPlayerOptions.options & BuildOptions.EnableCodeCoverage) != 0)
                {
                    if (!BuildProfileModuleUtil.IsBuildTargetSupportedByCoverage(buildPlayerOptions.target))
                        throw new ArgumentException("Code coverage is unavailable for the selected build target. Remove the EnableCodeCoverage build option.");
                }
            }

            try
            {

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Add BuildOptions.Development to the options bitmask when EnableDeepProfilingSupport is required.
  2. Remove BuildOptions.EnableDeepProfilingSupport if this is a release build.
  3. Wrap BuildOptions construction in a helper that auto-adds Development when any dev-only profiling flag is present.

Example fix

// before
var options = new BuildPlayerOptions
{
    options = BuildOptions.EnableDeepProfilingSupport,
    target = BuildTarget.StandaloneWindows64
};
BuildPipeline.BuildPlayer(options);

// after
var options = new BuildPlayerOptions
{
    options = BuildOptions.Development | BuildOptions.EnableDeepProfilingSupport,
    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

When it happens

Trigger: Calling BuildPipeline.BuildPlayer with a BuildOptions bitmask containing EnableDeepProfilingSupport without Development.

Common situations: Performance-investigation builds that enable deep profiling but inherit a release-oriented options base, or automated profiling scripts that set EnableDeepProfilingSupport independently of the Development flag.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/8bff2766a61ff5c5. Report an issue: GitHub.