{"record":{"id":"0285ce6f4f472c72","repo":"clockworklabs/SpacetimeDB","slug":"invalid-csproj-file-missing-project-tag","errorCode":null,"errorMessage":"Invalid .csproj file: missing </Project> tag","messagePattern":"Invalid \\.csproj file: missing </Project> tag","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/init.rs","lineNumber":1970,"sourceCode":"                    \"runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM\",\n                    \"8.0.0-*\",\n                );\n\n        if has_net8_native_aot_refs {\n            content\n        } else {\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            }\n        }\n    } else {\n        // .NET 10 AOT: directly set TFM to net10.0 (no conditional needed).\n        // ILCompiler.LLVM comes transitively via the SpacetimeDB.Runtime NuGet package.\n        content.replace(\n            \"<TargetFramework>net8.0</TargetFramework>\",\n            \"<TargetFramework>net10.0</TargetFramework>\",\n        )\n    };\n\n    std::fs::write(&csproj_path, new_content)?;\n    println!(\n        \"{} Added NativeAOT-LLVM project configuration to {}\",\n        \"✓\".green(),\n        csproj_path.display()\n    );\n","sourceCodeStart":1952,"sourceCodeEnd":1988,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/fdd647dfac506d0967cc4492e9fce380706c94cb/crates/cli/src/subcommands/init.rs#L1952-L1988","documentation":"On the .NET 8 AOT path, init appends ILCompiler.LLVM package references by locating the last `</Project>` closing tag and splicing before it. A csproj without that tag (truncated, hand-edited into invalid XML, or a forked template that dropped it) cannot be edited, so init aborts.","triggerScenarios":"--native-aot with --dotnet-version 8 against a malformed or truncated csproj; forked/custom template emitting nonstandard XML; file corrupted mid-write.","commonSituations":"Hand-edited csproj with mismatched tags; template forks; editors or lint tools mangling the file.","solutions":["Open the csproj and fix the XML so it ends with a proper `</Project>`; validate with `dotnet build`","Regenerate the C# project and re-apply custom edits afterwards","Forked templates: keep a well-formed csproj with the closing tag","Consider `--dotnet-version 10` AOT, which only string-replaces the TFM and is more tolerant"],"exampleFix":"<!-- before: truncated csproj -->\n<Project Sdk=\"Microsoft.NET.Sdk\">\n  <PropertyGroup>\n    <TargetFramework>net8.0</TargetFramework>\n<!-- after -->\n<Project Sdk=\"Microsoft.NET.Sdk\">\n  <PropertyGroup>\n    <TargetFramework>net8.0</TargetFramework>\n  </PropertyGroup>\n</Project>","handlingStrategy":"validation","validationCode":"# quick XML sanity check before init's AOT step\ngrep -q '</Project>' spacetimedb/StdbModule.csproj && echo ok || echo 'csproj not closed'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the generated csproj well-formed; run `dotnet build` after hand edits","Prefer the .NET 10 AOT path when possible; it only swaps the TFM string"],"tags":["spacetime-init","native-aot","csharp","csproj","malformed-xml"],"backgroundTag":"malformed-project-file","analyzedSha":"fdd647dfac506d0967cc4492e9fce380706c94cb","analyzedAt":"2026-08-30T19:52:08.972Z","contentChangedAt":"2026-08-30T19:52:08.972Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}