{"record":{"id":"f138787cb1a5bb58","repo":"clockworklabs/SpacetimeDB","slug":"dotnet-not-found-in-path-please-install-net-sdk","errorCode":null,"errorMessage":"dotnet not found in PATH. Please install .NET SDK 8.0 or 10.0.","messagePattern":"dotnet not found in PATH\\. Please install \\.NET SDK 8\\.0 or 10\\.0\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/csharp.rs","lineNumber":210,"sourceCode":"        };\n    }\n\n    let native_aot_flag = native_aot;\n\n    let project_global_json = find_global_json(project_path);\n    let cwd = std::env::current_dir()?;\n    let cwd_global_json = find_global_json(&cwd);\n    let dotnet_version_result = if project_global_json.is_some() {\n        Some(dotnet!(\"--version\").read())\n    } else if cwd_global_json.is_some() {\n        Some(duct::cmd!(\"dotnet\", \"--version\").read())\n    } else {\n        None\n    };\n    let dotnet_version_str = match dotnet_version_result {\n        Some(Ok(v)) => Some(v),\n        Some(Err(error)) if error.kind() == std::io::ErrorKind::NotFound => {\n            anyhow::bail!(\"dotnet not found in PATH. Please install .NET SDK 8.0 or 10.0.\")\n        }\n        Some(Err(error)) => anyhow::bail!(\"{error}\"),\n        None => None,\n    };\n\n    // Resolution order:\n    //   1. --dotnet-version CLI flag (explicit user override)\n    //   2. global.json-selected SDK, if one applies to the project or current directory\n    //   3. Single <TargetFramework> in the project's .csproj\n    //   4. .NET 10 default for missing or multi-target project context\n    let csproj_tfms = read_tfms_from_csproj(project_path);\n    let dotnet_major = dotnet_version_override\n        .or_else(|| dotnet_version_str.as_deref().and_then(parse_major_version))\n        .or_else(|| csproj_tfms.as_ref().and_then(CsprojTargetFrameworks::single_major))\n        .or(Some(10));\n\n    // Determine the build path based on SDK version and --native-aot flag.\n    let build_path = match (dotnet_major, native_aot_flag) {","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/9e0d92412ff2248f401a8ad12d535f2b5ac30912/crates/cli/src/tasks/csharp.rs#L192-L228","documentation":"When resolving the SDK for a C# module, the CLI runs `dotnet --version` if a global.json exists in the project directory or the current working directory. If the OS reports ErrorKind::NotFound, the dotnet executable is missing from PATH and the CLI bails with an install hint for .NET SDK 8.0 or 10.0. Without a global.json the probe is skipped entirely and the SDK is chosen from the csproj or defaults.","triggerScenarios":"`spacetime build` / `spacetime publish` on a C# project whose directory or cwd contains a global.json, on a machine where the dotnet executable is not installed or not on the PATH inherited by the spacetime process.","commonSituations":"Fresh CI images without the .NET SDK; dotnet installed via snap/homebrew but PATH not propagated to the shell or service running spacetime; Windows with only the .NET runtime (not the SDK) installed.","solutions":["Install the .NET SDK 8.0 or 10.0 (e.g. `winget install Microsoft.DotNet.SDK.8`, `apt install dotnet-sdk-8.0`, or the dotnet-install script).","If already installed, fix PATH so `command -v dotnet` succeeds in the same shell/CI step that runs spacetime.","In CI, add a .NET SDK setup step before the spacetime build step."],"exampleFix":"# before: CI step fails with 'dotnet not found in PATH'\n- run: spacetime build\n# after\n- uses: actions/setup-dotnet@v4\n  with: { dotnet-version: '8.0.x' }\n- run: spacetime build","handlingStrategy":"validation","validationCode":"# Fail fast with a clear message before building\ncommand -v dotnet >/dev/null 2>&1 || { echo \"dotnet not on PATH\" >&2; exit 1; }\ndotnet --version >/dev/null 2>&1 || exit 1\nspacetime build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a .NET SDK setup step (setup-dotnet or equivalent) before spacetime in CI.","For C# modules, or a global.json exists, the probe runs -- keep dotnet on PATH in that shell.","Verify `dotnet --info` works in the exact environment (container/service) that runs spacetime."],"tags":["csharp","dotnet","path","environment","toolchain"],"backgroundTag":"executable-not-on-path","analyzedSha":"9e0d92412ff2248f401a8ad12d535f2b5ac30912","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}