{"record":{"id":"ab5e59ede2961d91","repo":"Unity-Technologies/UnityCsReference","slug":"non-development-build-cannot-allow-code-coverage","errorCode":null,"errorMessage":"Non-development build cannot allow code coverage. Either add the Development build option, or remove the EnableCodeCoverage build option.","messagePattern":"Non-development build cannot allow code coverage\\. Either add the Development build option, or remove the EnableCodeCoverage build option\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs","lineNumber":239,"sourceCode":"                    throw new InvalidOperationException(\"The build cannot be appended.\");\n            }\n\n            if (buildPlayerOptions.scenes != null)\n            {\n                for (int i = 0; i < buildPlayerOptions.scenes.Length; i++)\n                    buildPlayerOptions.scenes[i] = buildPlayerOptions.scenes[i].Replace('\\\\', '/').Replace(\"//\", \"/\");\n            }\n\n            if ((buildPlayerOptions.options & BuildOptions.Development) == 0)\n            {\n                if ((buildPlayerOptions.options & BuildOptions.AllowDebugging) != 0)\n                {\n                    throw new ArgumentException(\"Non-development build cannot allow debugging. Either add the Development build option, or remove the AllowDebugging build option.\");\n                }\n\n                if ((buildPlayerOptions.options & BuildOptions.EnableCodeCoverage) != 0)\n                {\n                    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.\");","sourceCodeStart":221,"sourceCodeEnd":257,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/BuildPipeline.bindings.cs#L221-L257","documentation":"Thrown when BuildPlayer is called with BuildOptions.EnableCodeCoverage set but BuildOptions.Development is NOT set. Code coverage instrumentation requires the Development build pipeline because it injects coverage probes and links against coverage-specific runtime libraries.","triggerScenarios":"Calling BuildPipeline.BuildPlayer with options that include EnableCodeCoverage without Development — e.g., BuildOptions.EnableCodeCoverage alone or combined with non-development flags.","commonSituations":"CI pipelines that enable code coverage for automated test runs but fail to set the Development flag, or build configurations migrated from a development preset where the Development flag was accidentally removed.","solutions":["Add BuildOptions.Development to the options bitmask alongside EnableCodeCoverage.","Remove BuildOptions.EnableCodeCoverage if the build is intended to be a non-development release build.","Use a validation helper that enforces the Development prerequisite before calling BuildPlayer."],"exampleFix":"// before\nvar options = new BuildPlayerOptions\n{\n    options = BuildOptions.EnableCodeCoverage,\n    target = BuildTarget.StandaloneWindows64\n};\nBuildPipeline.BuildPlayer(options);\n\n// after\nvar options = new BuildPlayerOptions\n{\n    options = BuildOptions.Development | BuildOptions.EnableCodeCoverage,\n    target = BuildTarget.StandaloneWindows64\n};\nBuildPipeline.BuildPlayer(options);","handlingStrategy":"validation","validationCode":"BuildOptions EnsureDevelopmentForDevOnlyFlags(BuildOptions options)\n{\n    BuildOptions devOnlyFlags = BuildOptions.AllowDebugging |\n        BuildOptions.EnableCodeCoverage |\n        BuildOptions.EnableDeepProfilingSupport |\n        BuildOptions.ConnectWithProfiler;\n\n    if ((options & devOnlyFlags) != 0 && (options & BuildOptions.Development) == 0)\n        options |= BuildOptions.Development;\n    return options;\n}\n\n// Before BuildPlayer:\noptions.options = EnsureDevelopmentForDevOnlyFlags(options.options);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable Code Coverage only in Development builds.","Use the same EnsureDevelopment helper for all development-only flags.","Separate CI build configurations for coverage (Development) vs. release (clean options)."],"tags":["unity","build-pipeline","build-options","code-coverage","development-build"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}