{"record":{"id":"079376594e3dd721","repo":"stride3d/stride","slug":"could-not-find-a-supported-msbuild-toolset-version-expected","errorCode":null,"errorMessage":"Could not find a supported MSBuild toolset version (expected 16.0 or later)","messagePattern":"Could not find a supported MSBuild toolset version \\(expected 16\\.0 or later\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs","lineNumber":131,"sourceCode":"        return s_msBuildAssemblies.Contains(assemblyName.Name, StringComparer.OrdinalIgnoreCase);\n    }\n\n    private static void SetupMSBuildCurrentHostForOutOfProc(string dotNetSdkPath)\n    {\n        // Workaround for https://github.com/dotnet/msbuild/pull/7013 (dotnet.exe not properly detected by MSBuild so it fallbacks to launching our own executable instead)\n        var currentHostField = typeof(Microsoft.Build.Evaluation.Project).Assembly\n            .GetType(\"Microsoft.Build.BackEnd.NodeProviderOutOfProcBase\")?\n            .GetField(\"CurrentHost\", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);\n        currentHostField?.SetValue(null, Path.Combine(new DirectoryInfo(dotNetSdkPath).Parent.Parent.FullName, OperatingSystem.IsWindows() ? \"dotnet.exe\" : \"dotnet\"));\n    }\n\n    private static void CheckMSBuildToolset()\n    {\n        // Check that we can create a project\n        using var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection();\n        if (projectCollection.GetToolset(\"Current\") == null) // VS 2019+ (https://github.com/Microsoft/msbuild/issues/3778)\n        {\n            throw new InvalidOperationException(\"Could not find a supported MSBuild toolset version (expected 16.0 or later)\");\n        }\n    }\n}\n","sourceCodeStart":113,"sourceCodeEnd":135,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs#L113-L135","documentation":"Thrown by CheckMSBuildToolset (called from FindAndSetMSBuildVersion) when a fresh ProjectCollection has no 'Current' toolset, i.e. MSBuild assemblies loaded but no VS 2019+/modern .NET SDK toolset is registered. Without a toolset, projects cannot be evaluated or built.","triggerScenarios":"ProjectCollection.GetToolset(\"Current\") returns null — typically because only a legacy MSBuild toolset (pre-16.0) is installed or the .NET SDK's toolsets directory isn't discoverable.","commonSituations":"Machine with old Build Tools 15 only; broken/missing .NET SDK install where toolsets (Current/16.0 folders) are absent; custom DOTNET_ROOT pointing to an incomplete install.","solutions":["Install .NET SDK 6+ (or VS 2019+) so the 'Current' toolset exists.","Repair or reinstall the .NET SDK if the installation is broken/partial.","Check that custom DOTNET_ROOT/MSBuildSDKSPath env vars aren't misdirecting toolset lookup.","Run from a Developer Command Prompt so MSBuild environment variables resolve to the modern toolset."],"exampleFix":"// guard with clear guidance before use\nusing var pc = new ProjectCollection();\nif (pc.GetToolset(\"Current\") is null)\n    throw new InvalidOperationException(\"Install .NET SDK 6+ or VS2019+ to get the 'Current' MSBuild toolset.\");","handlingStrategy":"try-catch","validationCode":"using var pc = new Microsoft.Build.Evaluation.ProjectCollection();\nbool ok = pc.GetToolset(\"Current\") != null;\nif (!ok) throw new InvalidOperationException(\"MSBuild 'Current' toolset missing; install .NET SDK 6+ or VS2019+.\");","typeGuard":null,"tryCatchPattern":"try { PackageSessionPublicHelper.FindAndSetMSBuildVersion(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"toolset\"))\n{\n    // prompt the user to repair/install the .NET SDK\n}","preventionTips":["Install a full .NET SDK, not only standalone MSBuild.","Avoid legacy-only Build Tools (15.x) on machines running this code.","Watch for custom DOTNET_ROOT/MSBuild env vars pointing at incomplete installs.","Call FindAndSetMSBuildVersion once at startup to validate the environment."],"tags":["msbuild","dotnet","environment","build"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}