{"record":{"id":"b92cea7902394afa","repo":"clockworklabs/SpacetimeDB","slug":"the-selected-c-build-path-requires-the-net-desi","errorCode":null,"errorMessage":"The selected C# build path requires the .NET {desired_sdk_major} SDK, but the active SDK is .NET {active}.\nUpdate {} to select the .NET {desired_sdk_major} SDK, or run `spacetime init --dotnet-version {desired_sdk_major}` to create a project configured for this SDK.\nExpected global.json contents:\n{}","messagePattern":"The selected C# build path requires the \\.NET (.+?) SDK, but the active SDK is \\.NET (.+?)\\.\nUpdate (.+?) to select the \\.NET (.+?) SDK, or run `spacetime init --dotnet-version (.+?)` to create a project configured for this SDK\\.\nExpected global\\.json contents:\n(.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/csharp.rs","lineNumber":261,"sourceCode":"                .unwrap_or_else(|| \"<unknown>\".to_string());\n            anyhow::bail!(\n                \"Unsupported .NET SDK version: {}. SpacetimeDB requires .NET SDK 8.0 or 10.0.\\n\\\n                 If you have multiple versions installed, configure your project using \\\n                 https://learn.microsoft.com/en-us/dotnet/core/tools/global-json, \\\n                 or use --dotnet-version to specify the target version explicitly.\",\n                selected_version\n            );\n        }\n    };\n\n    let desired_sdk_major = match build_path {\n        CsharpBuildPath::Net8Jit | CsharpBuildPath::Net8Aot => 8,\n        CsharpBuildPath::Net10Aot => 10,\n    };\n    let active_sdk_major = dotnet_version_str.as_deref().and_then(parse_major_version);\n    if active_sdk_major != Some(desired_sdk_major) {\n        let active = dotnet_version_str.as_deref().map(str::trim).unwrap_or(\"<unknown>\");\n        anyhow::bail!(\n            \"The selected C# build path requires the .NET {desired_sdk_major} SDK, but the active SDK is .NET {active}.\\n\\\n             Update {} to select the .NET {desired_sdk_major} SDK, or run `spacetime init --dotnet-version {desired_sdk_major}` to create a project configured for this SDK.\\n\\\n             Expected global.json contents:\\n{}\",\n            project_path.join(\"global.json\").display(),\n            dotnet_global_json(desired_sdk_major)?\n        );\n    }\n\n    // Manage the EXPERIMENTAL_WASM_AOT environment variable for MSBuild.\n    // - Net8Aot / Net10Aot: must SET it — the ILCompiler.LLVM.targets import in\n    //   SpacetimeDB.Runtime.targets is gated on this env var. Without it, the NativeAOT\n    //   toolchain is not activated and dotnet produces managed DLLs instead of a .wasm.\n    // - Net8Jit: must UNSET it — prevents MSBuild from incorrectly enabling NativeAOT mode\n    //   when the env var is set globally (e.g., in CI).\n    match &build_path {\n        CsharpBuildPath::Net8Aot | CsharpBuildPath::Net10Aot => {\n            // SAFETY: We are single-threaded at this point and no other code is reading\n            // this environment variable concurrently.","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/tasks/csharp.rs#L243-L279","documentation":"Error \"The selected C# build path requires the .NET {desired_sdk_major} SDK, but the active SDK is .NET {active}.\nUpdate {} to select the .NET {desired_sdk_major} SDK, or run `spacetime init --dotnet-version {desired_sdk_major}` to create a project configured for this SDK.\nExpected global.json contents:\n{}\" thrown in clockworklabs/SpacetimeDB.","triggerScenarios":"Thrown at crates/cli/src/tasks/csharp.rs:261 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}