Unity-Technologies/UnityCsReference · critical · DirectoryNotFoundException
Bundled dotnet SDK not found at {sdkRoot}
Error message
Bundled dotnet SDK not found at {sdkRoot} What it means
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.
Source
Thrown at Editor/Mono/Scripting/ScriptCompilation/MsBuild/UnityEditorMSBuildPropsTargetsGeneration.cs:269
throw new FileNotFoundException($"No {prefix}*{suffix} package found in {sdkNugetsPath}");
}
private static string s_cachedDotnetRuntimeVersion;
// The .NET SDK version written to the generated global.json (sdk.version) must match the .NET SDK
// Unity ships. Read it from the SDK's authoritative ".version" metadata (the version is on the
// second line) rather than trusting the folder name, so a .NET upgrade (8 -> 10 -> ...) needs no
// change here. We return the full version (e.g. "10.0.102"), preserving minor/patch, and pick the
// highest if more than one SDK is present.
private static string GetDotnetRuntimeVersion()
{
if (s_cachedDotnetRuntimeVersion != null)
return s_cachedDotnetRuntimeVersion;
var sdkRoot = Path.Combine(EditorApplication.applicationScriptingPath, "DotNetSdk", "sdk");
if (!Directory.Exists(sdkRoot))
throw new DirectoryNotFoundException($"Bundled dotnet SDK not found at {sdkRoot}");
string bestVersion = null;
Version bestParsed = null;
foreach (var dir in Directory.EnumerateDirectories(sdkRoot))
{
// Each SDK folder ships a ".version" file whose second line is the SDK version, e.g.
// <commit hash>
// 8.0.318
// <rid>
var versionFile = Path.Combine(dir, ".version");
if (!File.Exists(versionFile))
continue;
var lines = File.ReadAllLines(versionFile);
if (lines.Length < 2)
continue;
var version = lines[1].Trim();
if (version.Length == 0)
continue;View on GitHub (pinned to 225b0fbdb5)
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.
Defensive patterns
Strategy: validation
Validate before calling
var sdkRoot = Path.Combine(EditorApplication.applicationScriptingPath, "DotNetSdk", "sdk");
if (!Directory.Exists(sdkRoot))
throw new DirectoryNotFoundException(
$"Bundled .NET SDK missing at {sdkRoot}; reinstall/repair the Unity Editor."); Prevention
- 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.
When it happens
Trigger: Generating the MSBuild global.json for script compilation when the bundled DotNetSdk/sdk folder is missing from the editor install.
Common situations: Corrupt/partial editor install, the bundled .NET SDK removed by a cleanup tool, or an altered application contents path.
Related errors
- Unity SDK nuget feed not found at {sdkNugetsPath}
- No {prefix}*{suffix} package found in {sdkNugetsPath}
- No SDK with a valid .version file found under {sdkRoot}
- Unsupported architecture {RuntimeInformation.ProcessArchitec
- Unsupported architecture {RuntimeInformation.ProcessArchitec
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/fa1e5d4d982220c0.
Report an issue: GitHub.