{"record":{"id":"b1392147d92be6f3","repo":"clockworklabs/SpacetimeDB","slug":"dotnet-version-is-only-supported-for-c-projects","errorCode":null,"errorMessage":"--dotnet-version is only supported for C# projects (--lang csharp)","messagePattern":"--dotnet-version is only supported for C# projects \\(--lang csharp\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":556,"sourceCode":"        config.spacetimedb_token().is_none()\n    };\n\n    let is_server_only = options.server_only;\n\n    let project_name = get_project_name(options, is_interactive).await?;\n    let project_path = get_project_path(options, &project_name, is_interactive, is_server_only).await?;\n    let local_database_name = get_local_database_name(options, &project_name, is_interactive)?;\n\n    let mut template_config = if is_interactive {\n        get_template_config_interactive(options, project_name, project_path.clone()).await?\n    } else {\n        get_template_config_non_interactive(options, project_name, project_path.clone()).await?\n    };\n\n    template_config.use_local = use_local;\n\n    if options.dotnet_version.is_some() && template_config.server_lang != Some(ServerLanguage::Csharp) {\n        anyhow::bail!(\"--dotnet-version is only supported for C# projects (--lang csharp)\");\n    }\n\n    // For C# projects, resolve the target .NET version before scaffolding.\n    let dotnet_major = if template_config.server_lang == Some(ServerLanguage::Csharp) {\n        let dotnet_major = options.dotnet_version.unwrap_or_else(resolve_default_dotnet_major);\n        println!(\"Targeting .NET SDK {dotnet_major}.\");\n        Some(dotnet_major)\n    } else {\n        None\n    };\n\n    ensure_empty_directory(\n        &template_config.project_name,\n        &template_config.project_path,\n        is_server_only,\n    )?;\n    init_from_template(\n        &template_config,","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/init.rs#L538-L574","documentation":"The `--dotnet-version` init flag targets the C# server template's .NET SDK major version and nothing else. init rejects the combination when the flag is set but the resolved server language is not C# — including templates that have no server module at all (server_lang of None). For C# projects the flag is otherwise optional; the CLI picks a default SDK when it's absent.","triggerScenarios":"`spacetime init my-app --lang rust --dotnet-version 8`; `--dotnet-version` combined with a `--template` whose stack is not C#; keeping the flag from a C# quickstart while switching languages.","commonSituations":"Copy-pasted flag sets from C# docs; iterating over languages in a scaffold script; template choices that changed after the flag was added to a command.","solutions":["Remove `--dotnet-version` from the invocation","Add `--lang csharp` (or pick a C# template) if you really want to pin the SDK","For C#, omit the flag entirely and let init resolve the default .NET SDK"],"exampleFix":"# before\nspacetime init my-app --non-interactive --project-name my-app --lang rust --dotnet-version 8\n\n# after\nspacetime init my-app --non-interactive --project-name my-app --lang rust\n\n# after (C# with pinned SDK)\nspacetime init my-app --non-interactive --project-name my-app --lang csharp --dotnet-version 8","handlingStrategy":"validation","validationCode":"# Only forward --dotnet-version for csharp server stacks:\nDOTNET_ARGS=()\nif [[ -n \"$DOTNET_VERSION\" ]]; then\n  case \"${LANG_ARG,,}\" in\n    csharp|c#) DOTNET_ARGS=(--dotnet-version \"$DOTNET_VERSION\") ;;\n    *) echo \"skipping --dotnet-version: lang=${LANG_ARG:-<template default>} is not csharp\" >&2 ;;\n  esac\nfi\nspacetime init --non-interactive --project-name my-app --lang \"$LANG_ARG\" \"${DOTNET_ARGS[@]}\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep --dotnet-version out of shared scaffold scripts; add it only in the csharp branch","For C#, omit the flag to get the CLI's default SDK resolution"],"tags":["init","dotnet","flag-combination","csharp"],"backgroundTag":"unsupported-flag-combination","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}