{"record":{"id":"833ad33633103503","repo":"clockworklabs/SpacetimeDB","slug":"could-not-find-stdbmodule-csproj-at","errorCode":null,"errorMessage":"Could not find StdbModule.csproj at {}","messagePattern":"Could not find StdbModule\\.csproj at (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":1916,"sourceCode":"    Ok(())\n}\n\n/// Adds NativeAOT-LLVM project configuration to an existing C# .csproj file and creates NuGet.Config.\n///\n/// The configuration differs depending on the target .NET version:\n///\n/// **.NET 8 AOT** (`--native-aot`): Keeps `net8.0` TFM and adds explicit ILCompiler.LLVM 8.0.0-*\n/// package references, gated on `EXPERIMENTAL_WASM_AOT=1`.\n///\n/// **.NET 10 AOT**: Replaces the TFM with `net10.0` directly (no conditional needed since the\n/// project is definitively targeting .NET 10). ILCompiler.LLVM refs are provided transitively\n/// by the SpacetimeDB.Runtime NuGet package.\n///\n/// Both paths need a NuGet.Config with the dotnet-experimental feed for ILCompiler.LLVM resolution.\nfn add_native_aot_packages_to_csproj(project_path: &Path, dotnet_major: Option<u8>) -> anyhow::Result<()> {\n    let csproj_path = project_path.join(\"StdbModule.csproj\");\n    if !csproj_path.exists() {\n        anyhow::bail!(\"Could not find StdbModule.csproj at {}\", csproj_path.display());\n    }\n\n    let content = std::fs::read_to_string(&csproj_path)?;\n\n    let new_content = if dotnet_major == Some(8) {\n        // .NET 8 AOT: keep net8.0 TFM, add explicit ILCompiler.LLVM package references.\n        let native_aot_config = r#\"\n  <ItemGroup Condition=\"'$(EXPERIMENTAL_WASM_AOT)' == '1'\">\n    <PackageReference Include=\"Microsoft.DotNet.ILCompiler.LLVM\" Version=\"8.0.0-*\" />\n    <PackageReference Include=\"runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM\" Version=\"8.0.0-*\" />\n  </ItemGroup>\n\"#;\n        if let Some(pos) = content.rfind(\"</Project>\") {\n            let (before, after) = content.split_at(pos);\n            format!(\"{}{}{}\", before.trim_end(), native_aot_config, after)\n        } else {\n            anyhow::bail!(\"Invalid .csproj file: missing </Project> tag\");\n        }","sourceCodeStart":1898,"sourceCodeEnd":1934,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/init.rs#L1898-L1934","documentation":"The NativeAOT configuration step (add_native_aot_packages_to_csproj) expects StdbModule.csproj at the project root and bails with the full expected path when it is missing (init.rs:1916). It is reached when building/publishing a C# module with native-aot enabled.","triggerScenarios":"Publishing with --native-aot (or native-aot: true in spacetime.json) from a directory that is not the C# module root, or after StdbModule.csproj was renamed or deleted.","commonSituations":"Running `spacetime publish` from the repo root instead of the module directory; a spacetime.json with a stale/wrong project-path; renaming the generated csproj; leaving native-aot enabled for a Rust or TypeScript target.","solutions":["Run from (or pass --project-path to) the directory that contains StdbModule.csproj","Rename your csproj back to StdbModule.csproj","Remove the native-aot setting/flag when building non-C# modules","Regenerate the module with `spacetime init` to restore the expected layout"],"exampleFix":"// before (repo root, no csproj here)\nspacetime publish --project-path . --native-aot\n// after\nspacetime publish --project-path modules/csharp --native-aot","handlingStrategy":"validation","validationCode":"test -f \"$PROJECT_DIR/StdbModule.csproj\" || {\n  echo \"StdbModule.csproj not found in $PROJECT_DIR\" >&2; exit 2\n}\nspacetime publish --project-path \"$PROJECT_DIR\" --native-aot","typeGuard":"fn is_csharp_module_root(dir: &std::path::Path) -> bool {\n    dir.join(\"StdbModule.csproj\").is_file()\n}","tryCatchPattern":null,"preventionTips":["Run publish from the module directory or pass an explicit --project-path","Keep the generated file name StdbModule.csproj","Disable native-aot in spacetime.json for non-C# targets"],"tags":["native-aot","csproj","file-not-found","csharp"],"backgroundTag":"file-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}