{"record":{"id":"3f8d894b2724225a","repo":"Unity-Technologies/UnityCsReference","slug":"code-coverage-is-unavailable-for-the-selected-buil","errorCode":null,"errorMessage":"Code coverage is unavailable for the selected build target. Remove the EnableCodeCoverage build option.","messagePattern":"Code coverage is unavailable for the selected build target\\. Remove the EnableCodeCoverage build option\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs","lineNumber":257,"sourceCode":"                    throw new ArgumentException(\"Non-development build cannot allow code coverage. Either add the Development build option, or remove the EnableCodeCoverage build option.\");\n                }\n\n                if ((buildPlayerOptions.options & BuildOptions.EnableDeepProfilingSupport) != 0)\n                {\n                    throw new ArgumentException(\"Non-development build cannot allow deep profiling support. Either add the Development build option, or remove the EnableDeepProfilingSupport build option.\");\n                }\n\n                if ((buildPlayerOptions.options & BuildOptions.ConnectWithProfiler) != 0)\n                {\n                    throw new ArgumentException(\"Non-development build cannot allow auto-connecting the profiler. Either add the Development build option, or remove the ConnectWithProfiler build option.\");\n                }\n            }\n            else\n            {\n                if ((buildPlayerOptions.options & BuildOptions.EnableCodeCoverage) != 0)\n                {\n                    if (!BuildProfileModuleUtil.IsBuildTargetSupportedByCoverage(buildPlayerOptions.target))\n                        throw new ArgumentException(\"Code coverage is unavailable for the selected build target. Remove the EnableCodeCoverage build option.\");\n                }\n            }\n\n            try\n            {\n                if (!BuildPlayerWindow.DefaultBuildMethods.IsBuildPathValid(buildPlayerOptions.locationPathName, out var msg))\n                    throw new ArgumentException($\"Invalid build path: '{buildPlayerOptions.locationPathName}'. {msg}\");\n\n                if (buildPlayerOptions.targetGroup == BuildTargetGroup.Standalone)\n                {\n                    if (buildPlayerOptions.subtarget == (int)StandaloneBuildSubtarget.Default)\n                        buildPlayerOptions.subtarget = (int)EditorUserBuildSettings.standaloneBuildSubtarget;\n\n                    EditorUserBuildSettings.standaloneBuildSubtarget = (StandaloneBuildSubtarget)buildPlayerOptions.subtarget;\n                }\n\n                return BuildPlayerInternal(\n                    buildPlayerOptions.scenes,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs#L239-L275","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar options = new BuildPlayerOptions\n{\n    options = BuildOptions.Development | BuildOptions.EnableCodeCoverage,\n    target = BuildTarget.WebGL\n};\nBuildPipeline.BuildPlayer(options);\n\n// after\nBuildOptions opts = BuildOptions.Development;\n// Only enable coverage for supported targets\nif (target == BuildTarget.StandaloneWindows64 ||\n    target == BuildTarget.StandaloneOSX ||\n    target == BuildTarget.Android)\n    opts |= BuildOptions.EnableCodeCoverage;\n\nvar options = new BuildPlayerOptions\n{\n    options = opts,\n    target = target\n};\nBuildPipeline.BuildPlayer(options);","handlingStrategy":"validation","validationCode":"BuildOptions FilterCodeCoverageByPlatform(BuildOptions options, BuildTarget target)\n{\n    bool coverageSupported = target == BuildTarget.StandaloneWindows64 ||\n        target == BuildTarget.StandaloneOSX ||\n        target == BuildTarget.StandaloneLinux64 ||\n        target == BuildTarget.Android;\n\n    if (!coverageSupported)\n        options &= ~BuildOptions.EnableCodeCoverage;\n    return options;\n}\n\n// Before BuildPlayer:\noptions.options = FilterCodeCoverageByPlatform(options.options, options.target);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["unity","build-pipeline","build-options","code-coverage","platform-support","development-build"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}