{"record":{"id":"238c3be4c26cb7e5","repo":"clockworklabs/SpacetimeDB","slug":"built-project-successfully-but-couldn-t-find-the-o","errorCode":null,"errorMessage":"Built project successfully but couldn't find the output file.","messagePattern":"Built project successfully but couldn't find the output file\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/csharp.rs","lineNumber":509,"sourceCode":"                    for entry in entries.flatten() {\n                        let path = entry.path();\n                        let name = path.file_name().unwrap_or_default().to_string_lossy();\n                        eprintln!(\n                            \"{}{}{}\",\n                            \"  \".repeat(depth + 1),\n                            name,\n                            if path.is_dir() { \"/\" } else { \"\" }\n                        );\n                        if path.is_dir() {\n                            list_recursive(&path, depth + 1);\n                        }\n                    }\n                }\n            }\n            list_recursive(&bin_dir, 0);\n        }\n    }\n    anyhow::bail!(\"Built project successfully but couldn't find the output file.\");\n}\n\npub(crate) fn dotnet_format(project_dir: &Path, files: impl IntoIterator<Item = PathBuf>) -> anyhow::Result<()> {\n    let cwd = std::env::current_dir().expect(\"Failed to retrieve current directory\");\n    duct::cmd(\n        \"dotnet\",\n        itertools::chain(\n            [\n                \"format\",\n                // We can't guarantee that the output lives inside a valid project or solution,\n                // so to avoid crash we need to use the `dotnet whitespace --folder` mode instead\n                // of a full style-aware formatter. Still better than nothing though.\n                \"whitespace\",\n                \"--folder\",\n                project_dir.to_str().unwrap(),\n                // Our files are marked with <auto-generated /> and will be skipped without this option.\n                \"--include-generated\",\n                \"--include\",","sourceCodeStart":491,"sourceCodeEnd":527,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/9e0d92412ff2248f401a8ad12d535f2b5ac30912/crates/cli/src/tasks/csharp.rs#L491-L527","documentation":"`dotnet publish` returned success and no .NET 7 stale path or bin/bin~ conflict was found, yet none of the known output locations (bin{,~}/{config}/{tfm}/wasi-wasm/{subdir}/StdbModule.wasm and the native/ variants) contain the module. As a diagnostic the CLI recursively lists the bin directory before bailing, so the actual layout is printed just above the error.","triggerScenarios":"`spacetime build` on a C# project whose publish output lands somewhere unexpected: csproj overrides of OutputPath/PublishDir, an SDK producing a different wasi-wasm RID layout, or a project not based on the SpacetimeDB module template (no StdbModule entry point, so a differently-named or missing wasm).","commonSituations":"Hand-rolled csprojs customizing output paths; renaming the module so the artifact is not StdbModule.wasm; SDK version changes to the wasi-wasm directory structure.","solutions":["Read the printed bin tree directly above the error -- it shows where the wasm actually landed (missing wasi-wasm/<rid> level, different file name, or nothing at all).","Restore standard output: remove OutputPath/PublishDir overrides and ensure the project is the SpacetimeDB C# template with the StdbModule entry point.","Clean (rm -rf bin obj) and rebuild.","If a newer SDK changed the layout, pin the known-good SDK via global.json."],"exampleFix":"// before: csproj customizes output\n<OutputPath>./out</OutputPath>\n// after: remove overrides so bin/<cfg>/<tfm>/wasi-wasm/... is produced\n// (delete the OutputPath/PublishDir properties)","handlingStrategy":"fallback","validationCode":"# Sanity-check the template before building: entry point and standard output\n ls \"$PROJECT\"/StdbModule.cs 2>/dev/null || echo \"warning: not a standard SpacetimeDB C# template\" >&2\n grep -qE 'OutputPath|PublishDir' \"$PROJECT\"/*.csproj && echo \"warning: custom output paths may hide the wasm\" >&2\nspacetime build","typeGuard":null,"tryCatchPattern":"spacetime build || { echo \"build output not found; searching:\"; find \"$PROJECT\"/bin -name '*.wasm' -newer \"$PROJECT\"/*.csproj; }","preventionTips":["Build from the official `spacetime init` C# template so the StdbModule.wasm path is standard.","Avoid OutputPath/PublishDir overrides in module csprojs.","Pin the SDK via global.json so wasi-wasm layout changes do not surprise builds."],"tags":["csharp","build-output","artifacts","diagnostics"],"backgroundTag":"build-output-not-found","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"}