{"record":{"id":"fa1e5d4d982220c0","repo":"Unity-Technologies/UnityCsReference","slug":"bundled-dotnet-sdk-not-found-at-sdkroot","errorCode":null,"errorMessage":"Bundled dotnet SDK not found at {sdkRoot}","messagePattern":"Bundled dotnet SDK not found at (.+?)","errorType":"exception","errorClass":"DirectoryNotFoundException","httpStatus":null,"severity":"critical","filePath":"Editor/Mono/Scripting/ScriptCompilation/MsBuild/UnityEditorMSBuildPropsTargetsGeneration.cs","lineNumber":269,"sourceCode":"\n        throw new FileNotFoundException($\"No {prefix}*{suffix} package found in {sdkNugetsPath}\");\n    }\n\n    private static string s_cachedDotnetRuntimeVersion;\n\n    // The .NET SDK version written to the generated global.json (sdk.version) must match the .NET SDK\n    // Unity ships. Read it from the SDK's authoritative \".version\" metadata (the version is on the\n    // second line) rather than trusting the folder name, so a .NET upgrade (8 -> 10 -> ...) needs no\n    // change here. We return the full version (e.g. \"10.0.102\"), preserving minor/patch, and pick the\n    // highest if more than one SDK is present.\n    private static string GetDotnetRuntimeVersion()\n    {\n        if (s_cachedDotnetRuntimeVersion != null)\n            return s_cachedDotnetRuntimeVersion;\n\n        var sdkRoot = Path.Combine(EditorApplication.applicationScriptingPath, \"DotNetSdk\", \"sdk\");\n        if (!Directory.Exists(sdkRoot))\n            throw new DirectoryNotFoundException($\"Bundled dotnet SDK not found at {sdkRoot}\");\n\n        string bestVersion = null;\n        Version bestParsed = null;\n        foreach (var dir in Directory.EnumerateDirectories(sdkRoot))\n        {\n            // Each SDK folder ships a \".version\" file whose second line is the SDK version, e.g.\n            //   <commit hash>\n            //   8.0.318\n            //   <rid>\n            var versionFile = Path.Combine(dir, \".version\");\n            if (!File.Exists(versionFile))\n                continue;\n            var lines = File.ReadAllLines(versionFile);\n            if (lines.Length < 2)\n                continue;\n            var version = lines[1].Trim();\n            if (version.Length == 0)\n                continue;","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/MsBuild/UnityEditorMSBuildPropsTargetsGeneration.cs#L251-L287","documentation":"Thrown by GetDotnetRuntimeVersion (UnityEditorMSBuildPropsTargetsGeneration.cs:269, DirectoryNotFoundException) when the bundled .NET SDK directory at <applicationScriptingPath>/DotNetSdk/sdk does not exist. Unity reads the SDK version from each SDK folder's '.version' file to write sdk.version into the generated global.json; if the SDK root is absent the version cannot be discovered.","triggerScenarios":"Generating the MSBuild global.json for script compilation when the bundled DotNetSdk/sdk folder is missing from the editor install.","commonSituations":"Corrupt/partial editor install, the bundled .NET SDK removed by a cleanup tool, or an altered application contents path.","solutions":["Reinstall/repair the Unity Editor to restore the bundled DotNetSdk/sdk directory.","Confirm EditorApplication.applicationScriptingPath resolves to the correct install and that the DotNetSdk tree is intact."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var sdkRoot = Path.Combine(EditorApplication.applicationScriptingPath, \"DotNetSdk\", \"sdk\");\nif (!Directory.Exists(sdkRoot))\n    throw new DirectoryNotFoundException(\n        $\"Bundled .NET SDK missing at {sdkRoot}; reinstall/repair the Unity Editor.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the bundled DotNetSdk tree intact within the editor install.","Verify applicationScriptingPath points at the correct, complete editor layout.","Repair the editor install if the SDK folder is missing."],"tags":["unity","msbuild","dotnet","sdk","install","environment"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}