SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

Cannot run `spacetime publish` when csproj + sln live in same folder

Open AndreasHassing opened this issue 8 months ago • 4 comments

I've been going through https://spacetimedb.com/docs/unity/part-3.

When opening the server-csharp folder in VS Code:

cd C:\dev\unity-games\blackholio\server-csharp
code .

It (C# DevKit?) automatically creates a server-csharp.sln file in the same folder as StdbModule.csproj.

After this, if I run spacetime publish --server local blackholio I get an error:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
Error: command ["dotnet", "publish", "-c", "Release", "-v", "quiet"] exited with code 1

There is no way to specify that StdbModule.csproj should be built.

--build-options is only used to specify additional options to the spacetime build command which gets invoked as part of spacetime publish.

Static dotnet publish execution: https://github.com/clockworklabs/SpacetimeDB/blob/651f79d22cc4bb1c3c996ef2436186501a5d83bd/crates/cli/src/tasks/csharp.rs#L70C5-L70C65

AndreasHassing avatar Apr 12 '25 23:04 AndreasHassing

Just put it in a directory (module in blow). like this:

│  spacetimedb.sln
│
└─── module
        .gitignore
        global.json
        Lib.cs
        StdbModule.csproj

m-nt avatar Apr 13 '25 09:04 m-nt

Just put it in a directory (module in blow). like this:

│  spacetimedb.sln
│
└─── module
        .gitignore
        global.json
        Lib.cs
        StdbModule.csproj

That works, too. I just created a PowerShell script to temporarily rename the sln-file before invoking spacetime CLI.

To avoid others having the same problem, it may make sense to fix it at the source 😊.

AndreasHassing avatar Apr 13 '25 11:04 AndreasHassing

Will fix, ticket has been triaged 👍

jdetter avatar Apr 13 '25 12:04 jdetter

It (C# DevKit?) automatically creates a server-csharp.sln file in the same folder as StdbModule.csproj.

VS Code also has a setting to prevent this, which is disabled by default: Dotnet: Preview Solution-free Workspace Mode

PatrekurTh avatar Apr 25 '25 14:04 PatrekurTh