SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Build command can't find output file in subdirectory with custom output path

Open custompro12 opened this issue 9 months ago • 3 comments

Description

When a SpacetimeDB C# module is:

  1. Located in a subdirectory (part of a multi-app repo)
  2. Using root-level Directory.Build.props to 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

  1. Create a multi-app directory structure:
my-project/
  apps/
    api/  # SpacetimeDB module here
    other-app/
  dist/
  Directory.Build.props
  1. Add Directory.Build.props in 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>
  1. Initialize SpacetimeDB module in apps/api:
cd apps/api
spacetime init --lang csharp .
  1. 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:

  1. The build command should respect the output paths configured in Directory.Build.props, or
  2. 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#

custompro12 avatar Mar 16 '25 22:03 custompro12

Thanks for reporting! We'll investigate getting this fixed.

bfops avatar Apr 02 '25 17:04 bfops

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.

bfops avatar Apr 04 '25 18:04 bfops

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.

cloutiertyler avatar Apr 09 '25 02:04 cloutiertyler