Build command can't find output file in subdirectory with custom output path
Description
When a SpacetimeDB C# module is:
- Located in a subdirectory (part of a multi-app repo)
- Using root-level
Directory.Build.propsto customize output paths
The spacetime build command reports success but fails with "Built project successfully but couldn't find the output file".
Steps to Reproduce
- Create a multi-app directory structure:
my-project/
apps/
api/ # SpacetimeDB module here
other-app/
dist/
Directory.Build.props
- Add
Directory.Build.propsin root with dynamic output paths:
<Project>
<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<ProjectRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</ProjectRelativePath>
<BaseOutputPath>$(RepoRoot)dist/$(ProjectRelativePath)</BaseOutputPath>
<OutputPath>$(BaseOutputPath)</OutputPath>
<BaseIntermediateOutputPath>$(RepoRoot)dist/intermediates/$(ProjectRelativePath)/obj</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>
<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
</PropertyGroup>
</Project>
- Initialize SpacetimeDB module in apps/api:
cd apps/api
spacetime init --lang csharp .
- Try to build:
spacetime build --project-path .
Current Behavior
Build appears to succeed but errors with: "Built project successfully but couldn't find the output file"
Expected Behavior
Either:
- The build command should respect the output paths configured in Directory.Build.props, or
- The build command could be simplified to just handle compilation without needing to locate the output files. Any commands that need the built files (like
generate) could handle file location separately.
Environment
- SpacetimeDB CLI version: 1.0.0
- Project type: C#
Thanks for reporting! We'll investigate getting this fixed.
Implementation note:
I've investigated a bit. It looks like we could add this to the .csproj template:
<Target Name="PrintOutputPath">
<Message Text="$(OutputPath)" Importance="High" />
</Target>
and then in spacetime build, we could parse the output of dotnet msbuild -nologo -t:PrintOutputPath rather than using our hardcoded paths.
I also ran into this issue on my own and had to rediscover this. For now I'm putting in our docs that this just how it is until this issue is closed.