{"record":{"id":"23b87dafc33d05e6","repo":"Unity-Technologies/UnityCsReference","slug":"getil2cppbcldistributiondirectory-is-only-supporte","errorCode":null,"errorMessage":"GetIl2CppBclDistributionDirectory is only supported for IL2CPP with the NET profile.","messagePattern":"GetIl2CppBclDistributionDirectory is only supported for IL2CPP with the NET profile\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs","lineNumber":437,"sourceCode":"                Path.Combine(GetIl2CppBclDistributionDirectory(target, namedTarget, buildOptions), \"lib\");\n            if (Directory.Exists(libDirectory))\n                result.Add(libDirectory);\n            else\n                Debug.LogError($\"Unable to find il2cpp bcl directory: {libDirectory}\");\n            return result;\n        }\n\n        internal static string GetIl2CppBclDistributionDirectory(BuildTarget target, BuildOptions buildOptions)\n        {\n            var namedTarget = NamedBuildTarget.FromActiveSettings(target);\n            return GetIl2CppBclDistributionDirectory(target, namedTarget, buildOptions);\n        }\n\n        static string GetIl2CppBclDistributionDirectory(BuildTarget target, NamedBuildTarget namedTarget, BuildOptions buildOptions)\n        {\n#pragma warning disable CS0618\n            if (PlayerSettings.GetApiCompatibilityLevel(namedTarget) != ApiCompatibilityLevel.NET)\n                throw new NotSupportedException($\"{nameof(GetIl2CppBclDistributionDirectory)} is only supported for IL2CPP with the NET profile.\");\n#pragma warning restore CS0618\n\n            var gotBuildTarget = BuildTargetDiscovery.TryGetBuildTarget(target, out var ibuildTarget);\n            if (!gotBuildTarget || ibuildTarget.ScriptingPlatformProperties == null)\n            {\n                return null;\n            }\n            return Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(target, buildOptions, false), ibuildTarget.ScriptingPlatformProperties.IL2CPPBCLDirectory);\n        }\n\n        internal static string[] GetBuilderDefinedDefines(BuildTarget target, ApiCompatibilityLevel apiCompatibilityLevel, bool enableIl2CppDebugger)\n        {\n            List<string> defines = new List<string>();\n\n            switch (apiCompatibilityLevel)\n            {\n                case ApiCompatibilityLevel.NET_Unity_4_8:\n                case ApiCompatibilityLevel.NET_Standard:","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/BuildPipeline/Il2Cpp/IL2CPPUtils.cs#L419-L455","documentation":"Thrown by GetIl2CppBclDistributionDirectory when the active scripting backend is IL2CPP but the API compatibility level is not ApiCompatibilityLevel.NET. The IL2CPP Base Class Library (BCL) distribution directory lookup is meaningful only for the legacy .NET profile; for other profiles (e.g. .NET Standard, .NET 4.x sub-levels) there is no single BCL distribution folder to return.","triggerScenarios":"Calling GetIl2CppBclDistributionDirectory(target, buildOptions) while PlayerSettings.GetApiCompatibilityLevel(namedTarget) returns anything other than ApiCompatibilityLevel.NET (e.g. NET_Standard, NET_Unity_4_8 used in a non-IL2CPP path, or Level2/Level3 subset levels).","commonSituations":"A custom build pipeline or editor script invokes this helper expecting it to work for any IL2CPP build; project Player Settings have been set to .NET Standard 2.1 or a .NET subset instead of the full .NET profile; upgrading a project where the API compatibility level defaulted to a non-NET value.","solutions":["Set Player Settings > Other > Api Compatibility Level to '.NET' (ApiCompatibilityLevel.NET) for the target group before invoking this method.","Guard the call: only call GetIl2CppBclDistributionDirectory when GetApiCompatibilityLevel(namedTarget) == ApiCompatibilityLevel.NET.","If you need BCL info for .NET Standard, use the IL2CPP toolchain paths specific to that TFM rather than this method."],"exampleFix":"// before\nvar dir = Il2CppBuildPipelineExtensions.GetIl2CppBclDistributionDirectory(target, buildOptions);\n\n// after\nvar namedTarget = NamedBuildTarget.FromActiveSettings(target);\n#pragma warning disable CS0618\nif (PlayerSettings.GetApiCompatibilityLevel(namedTarget) == ApiCompatibilityLevel.NET)\n#pragma warning restore CS0618\n{\n    var dir = Il2CppBuildPipelineExtensions.GetIl2CppBclDistributionDirectory(target, buildOptions);\n}","handlingStrategy":"validation","validationCode":"var namedTarget = NamedBuildTarget.FromActiveSettings(target);\n#pragma warning disable CS0618\nbool canCall = PlayerSettings.GetApiCompatibilityLevel(namedTarget) == ApiCompatibilityLevel.NET;\n#pragma warning restore CS0618\nif (!canCall) return null; // or surface a user-facing message","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep API Compatibility Level set to .NET for IL2CPP-only helpers that need the BCL distribution dir.","Wrap editor utilities that call this method in a compatibility-level guard."],"tags":["il2cpp","build-pipeline","api-compatibility","player-settings"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}