{"record":{"id":"c42a473d92fb9e6b","repo":"Unity-Technologies/UnityCsReference","slug":"no-sdk-with-a-valid-version-file-found-under-sdk","errorCode":null,"errorMessage":"No SDK with a valid .version file found under {sdkRoot}","messagePattern":"No SDK with a valid \\.version file found under (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"Editor/Mono/Scripting/ScriptCompilation/MsBuild/UnityEditorMSBuildPropsTargetsGeneration.cs","lineNumber":303,"sourceCode":"            var version = lines[1].Trim();\n            if (version.Length == 0)\n                continue;\n            // Strip any \"-preview.x\" suffix for comparison, but return the full version string.\n            var numeric = version;\n            var dash = numeric.IndexOf('-');\n            if (dash >= 0)\n                numeric = numeric.Substring(0, dash);\n            if (!Version.TryParse(numeric, out var parsed))\n                continue;\n            if (bestParsed == null || parsed > bestParsed)\n            {\n                bestParsed = parsed;\n                bestVersion = version;\n            }\n        }\n\n        if (bestVersion == null)\n            throw new FileNotFoundException($\"No SDK with a valid .version file found under {sdkRoot}\");\n\n        return s_cachedDotnetRuntimeVersion = bestVersion;\n    }\n\n    public static void UpdateInstallPathFile()\n    {\n        Directory.CreateDirectory(Path.Combine(\"Library\", \"MSBuild\"));\n\n        //This is used by the host to find certain important files thats part of the unity install\n        File.WriteAllText(Path.Combine(\"Library\", \"MSBuild\", \"unitylocation.txt\"), EditorApplication.applicationContentsPath);\n    }\n\n    private static void UpdateReferencesProps(BuildTarget buildTarget)\n    {\n        var editorBuildReferences = GetModulesAssemblyPaths(true, buildTarget);\n        var playerBuildReferences = GetModulesAssemblyPaths(false, buildTarget);\n        PropsGenerator.Instance.UpdateReferencesProps(editorBuildReferences, playerBuildReferences);\n    }","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/Scripting/ScriptCompilation/MsBuild/UnityEditorMSBuildPropsTargetsGeneration.cs#L285-L321","documentation":"Thrown by GetDotnetRuntimeVersion (UnityEditorMSBuildPropsTargetsGeneration.cs:303, FileNotFoundException) when the bundled DotNetSdk/sdk directory exists and contains subfolders, but none of them has a '.version' file whose second line parses as a .NET SDK version (after stripping a '-preview' style suffix). bestVersion stays null, so no SDK version can be selected for global.json.","triggerScenarios":"The SDK folders exist but each '.version' file is missing, empty, malformed, or its version token fails Version.TryParse. Only the highest parseable version is chosen; if zero parse, this fires.","commonSituations":"Corrupted/incomplete bundled SDK install where version metadata files were deleted or truncated. A repackaged SDK whose '.version' format differs from the expected two-line layout.","solutions":["Reinstall/repair the Unity Editor so each DotNetSdk/sdk/<ver>/.version file is present with a valid version on its second line.","If you maintain a custom SDK layout, ensure each SDK folder ships a '.version' file with the version string (e.g. '8.0.318') on the second line and that it parses as MAJOR.MINOR.PATCH."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var sdkRoot = Path.Combine(EditorApplication.applicationScriptingPath, \"DotNetSdk\", \"sdk\");\nvar valid = Directory.EnumerateDirectories(sdkRoot)\n    .Select(d => Path.Combine(d, \".version\"))\n    .Where(File.Exists)\n    .Select(f => File.ReadLines(f).Skip(1).FirstOrDefault())\n    .Select(line => line?.Split('-')[0])\n    .Where(t => Version.TryParse(t, out _))\n    .OrderByDescending(t => Version.Parse(t))\n    .FirstOrDefault();\nif (valid == null)\n    throw new FileNotFoundException(\n        $\"No SDK with a valid .version file under {sdkRoot}; repair the editor install.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure each bundled SDK folder ships a '.version' file with the version on the second line.","Do not delete or truncate '.version' files in the DotNetSdk/sdk tree.","After modifying a custom SDK layout, validate that at least one '.version' parses as MAJOR.MINOR.PATCH."],"tags":["unity","msbuild","dotnet","sdk","version","install","environment"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}