Unity-Technologies/UnityCsReference · error · ArgumentException
Code coverage is unavailable for the selected build target.
Error message
Code coverage is unavailable for the selected build target. Remove the EnableCodeCoverage build option.
What it means
Thrown when BuildPlayer is called with BuildOptions.Development and BuildOptions.EnableCodeCoverage on a build target that does not support code coverage. The check is delegated to BuildProfileModuleUtil.IsBuildTargetSupportedByCoverage, which validates platform-level coverage instrumentation support.
Source
Thrown at Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs:257
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
{
if (!BuildPlayerWindow.DefaultBuildMethods.IsBuildPathValid(buildPlayerOptions.locationPathName, out var msg))
throw new ArgumentException($"Invalid build path: '{buildPlayerOptions.locationPathName}'. {msg}");
if (buildPlayerOptions.targetGroup == BuildTargetGroup.Standalone)
{
if (buildPlayerOptions.subtarget == (int)StandaloneBuildSubtarget.Default)
buildPlayerOptions.subtarget = (int)EditorUserBuildSettings.standaloneBuildSubtarget;
EditorUserBuildSettings.standaloneBuildSubtarget = (StandaloneBuildSubtarget)buildPlayerOptions.subtarget;
}
return BuildPlayerInternal(
buildPlayerOptions.scenes,View on GitHub (pinned to 225b0fbdb5)
Solutions
- Remove BuildOptions.EnableCodeCoverage from the options bitmask for the unsupported target.
- Switch the build target to one that supports coverage (typically Standalone Windows/Mac/Linux or Android).
- Conditionally set EnableCodeCoverage only when BuildProfileModuleUtil.IsBuildTargetSupportedByCoverage returns true for the target.
Example fix
// before
var options = new BuildPlayerOptions
{
options = BuildOptions.Development | BuildOptions.EnableCodeCoverage,
target = BuildTarget.WebGL
};
BuildPipeline.BuildPlayer(options);
// after
BuildOptions opts = BuildOptions.Development;
// Only enable coverage for supported targets
if (target == BuildTarget.StandaloneWindows64 ||
target == BuildTarget.StandaloneOSX ||
target == BuildTarget.Android)
opts |= BuildOptions.EnableCodeCoverage;
var options = new BuildPlayerOptions
{
options = opts,
target = target
};
BuildPipeline.BuildPlayer(options); Defensive patterns
Strategy: validation
Validate before calling
BuildOptions FilterCodeCoverageByPlatform(BuildOptions options, BuildTarget target)
{
bool coverageSupported = target == BuildTarget.StandaloneWindows64 ||
target == BuildTarget.StandaloneOSX ||
target == BuildTarget.StandaloneLinux64 ||
target == BuildTarget.Android;
if (!coverageSupported)
options &= ~BuildOptions.EnableCodeCoverage;
return options;
}
// Before BuildPlayer:
options.options = FilterCodeCoverageByPlatform(options.options, options.target); Prevention
- Check platform coverage support before enabling EnableCodeCoverage.
- Maintain a list of coverage-supported platforms in your build configuration.
- Gate coverage in CI to only run on supported platforms.
When it happens
Trigger: Calling BuildPipeline.BuildPlayer with Development | EnableCodeCoverage for a target like WebGL, certain consoles, or any platform whose coverage module is not installed or not implemented.
Common situations: A CI coverage pipeline configured for one platform is pointed at an unsupported target, or a team enables EnableCodeCoverage globally without checking which platforms their project targets. Also occurs when a platform module that provided coverage support was removed in a Unity update.
Related errors
- Non-development build cannot allow code coverage. Either add
- Non-development build cannot allow debugging. Either add the
- Non-development build cannot allow deep profiling support. E
- Non-development build cannot allow auto-connecting the profi
- The build target does not support build appending.
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/3f8d894b2724225a.
Report an issue: GitHub.