Skip to content

Commit 843993f

Browse files
Isolate Godot NuGet restore from Unity package cache (#5136)
# Description of Changes A follow-on to #5133 that fixes another Godot flake that was observed after #5133 merged. Specifically a C# SDK regen flake where the Godot package restore path reused `sdks/csharp/packages`, which is also the Unity-visible package cache. During `cargo regen csharp dlls`, the Godot flow previously did this: - cleared `sdks/csharp/packages/godotsharp` - cleared `sdks/csharp/obj~/godot` - restored the Godot project back into `sdks/csharp/packages` - packed the Godot project using that same Unity-visible package area That meant a Godot-only cleanup could delete package content under the Unity SDK package cache. If a previous GodotSharp restore was partial or stale, regen tried to fix it by deleting `packages/godotsharp`, but that path is visible to Unity and can cause dirty/missing package content during regen. With this change, Godot restore state is now isolated under `sdks/csharp/obj~/godot/packages`, and the regen flow becomes: - clear only `sdks/csharp/obj~/godot` - restore the Godot project into `sdks/csharp/obj~/godot/packages` - pack the Godot project under the same path Clearing `obj~/godot` now removes both Godot intermediates and Godot-only NuGet packages, while leaving the normal Unity SDK package cache under `sdks/csharp/packages` untouched. # API and ABI breaking changes N/A # Expected complexity level and risk 1 # Testing - [x] `unity-testsuite` passes
1 parent 2af138f commit 843993f

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

sdks/csharp/SpacetimeDB.ClientSDK.Godot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<AssemblyVersion>2.3.0</AssemblyVersion>
2020
<Version>2.3.0</Version>
2121
<DefaultItemExcludes>$(DefaultItemExcludes);*~/**</DefaultItemExcludes>
22-
<RestorePackagesPath>packages</RestorePackagesPath>
22+
<RestorePackagesPath>obj~/godot/packages</RestorePackagesPath>
2323
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
2424
<DefineConstants>$(DefineConstants);GODOT</DefineConstants>
2525
<!-- Godot.NET.Sdk defaults to .godot/mono/temp; build this package like the regular C# SDK. -->

tools/regen/src/csharp.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::fs;
77
use std::path::{Path, PathBuf};
88

99
const BSATN_PACKAGE_ID: &str = "spacetimedb.bsatn.runtime";
10-
const GODOTSHARP_PACKAGE_ID: &str = "godotsharp";
1110
const RUNTIME_PACKAGE_ID: &str = "spacetimedb.runtime";
1211

1312
fn workspace_dir() -> PathBuf {
@@ -117,7 +116,7 @@ fn clear_restored_package_dirs(pkg_id: &str) -> Result<()> {
117116
Ok(())
118117
}
119118

120-
fn clear_godot_intermediate_outputs() -> Result<()> {
119+
fn clear_godot_regen_dir() -> Result<()> {
121120
let godot_obj_dir = sdk_dir().join("obj~/godot");
122121
if godot_obj_dir.exists() {
123122
fs::remove_dir_all(&godot_obj_dir)?;
@@ -219,10 +218,11 @@ pub fn regen_dlls() -> Result<()> {
219218
clear_restored_package_dirs(RUNTIME_PACKAGE_ID)?;
220219

221220
// Some Unity runners have had partially restored GodotSharp package state in the past.
222-
// Clear the package and restore outputs so NuGet cannot reuse assets missing GodotSharp.dll.
221+
// Godot restores packages under obj~/godot/packages, so clearing obj~/godot removes
222+
// both intermediates and Godot-only packages without touching Unity-visible packages.
223+
// This prevents NuGet from reusing assets missing GodotSharp.dll.
223224
// See https://github.com/clockworklabs/SpacetimeDB/pull/5133 for more details.
224-
clear_restored_package_dirs(GODOTSHARP_PACKAGE_ID)?;
225-
clear_godot_intermediate_outputs()?;
225+
clear_godot_regen_dir()?;
226226

227227
cmd!(
228228
"dotnet",
@@ -244,6 +244,7 @@ pub fn regen_dlls() -> Result<()> {
244244
"-p:BaseOutputPath=bin~/",
245245
"-p:BaseIntermediateOutputPath=obj~/godot/",
246246
"-p:MSBuildProjectExtensionsPath=obj~/godot/",
247+
"-p:RestorePackagesPath=obj~/godot/packages",
247248
)
248249
.dir(&sdk)
249250
.run()?;
@@ -272,7 +273,8 @@ pub fn regen_dlls() -> Result<()> {
272273
"-p:BaseOutputPath=bin~/",
273274
// TODO: It should be possible to put this in Directory.Build.props, but it caused CI failures when we did.
274275
"-p:BaseIntermediateOutputPath=obj~/godot/",
275-
"-p:MSBuildProjectExtensionsPath=obj~/godot/"
276+
"-p:MSBuildProjectExtensionsPath=obj~/godot/",
277+
"-p:RestorePackagesPath=obj~/godot/packages",
276278
)
277279
.dir(&sdk)
278280
.run()?;

0 commit comments

Comments
 (0)