-
Notifications
You must be signed in to change notification settings - Fork 669
Add cargo ci dlls command for building C# DLLs and NuGet packages
#4033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…d NuGet packages
| "restore", | ||
| "SpacetimeDB.ClientSDK.csproj", | ||
| "--configfile", | ||
| &nuget_config_path_str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow TIL there's a configfile param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah but only on restore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems like by far the cleanest way to do this dance
tools/ci/src/main.rs
Outdated
| return Ok(()); | ||
| } | ||
|
|
||
| for entry in fs::read_dir(&pkg_root)? { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is there a reason we don't remove_dir_all(&pkg_root)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point, latest update should now do exactly that
tools/ci/src/main.rs
Outdated
|
|
||
| match best.as_ref() { | ||
| None => best = Some((version, entry.path())), | ||
| Some((best_v, _)) if version > *best_v => best = Some((version, entry.path())), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it's fine to just pick the first dir (and maybe assert that there is at most 1), especially since we nuke all subdirs of the package's directory beforehand anyway.
(if you make that change, I would add a comment to that effect though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great point. Implemented, and added an error message instead of a comment.
tools/ci/src/main.rs
Outdated
| copy_overlay_dir(&src_path, &dst_path)?; | ||
| } | ||
| } else { | ||
| if let Some(file_name) = dst_path.file_name().and_then(|n| n.to_str()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe we should just save entry.file_name() above (or clone it here) since dst_path.file_name is essentially derived from it anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewrote the .meta detection to avoid string conversion entirely.
So if src_path.extension() == "meta", derive the asset path via dst_path.file_stem() (and expect it exists)
Copy .meta only if the corresponding asset exists in the restored dir, otherwise delete stale .meta
tools/ci/src/main.rs
Outdated
| copy_overlay_dir(&src_path, &dst_path)?; | ||
| } | ||
| } else { | ||
| if let Some(file_name) = dst_path.file_name().and_then(|n| n.to_str()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but more importantly: should this be an if let Some(...)? shouldn't we unwrap or something? wouldn't we want to know if this failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. The rewrite fixes this. Now uses path-based .extension()/.file_stem() so we don’t rely on UTF-8 or string suffix logic, and we fail with a message if something unexpected happens.
tools/ci/src/main.rs
Outdated
| } | ||
| } else { | ||
| if let Some(file_name) = dst_path.file_name().and_then(|n| n.to_str()) { | ||
| if let Some(asset_name) = file_name.strip_suffix(".meta") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar here: if the strip_suffix failed, wouldn't we want to error out? when would we not expect this to be Some?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, the rewrite should cover this
| if let Some(parent) = dst_path.parent() { | ||
| fs::create_dir_all(parent)?; | ||
| } | ||
| fs::copy(&src_path, &dst_path)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this must be related to my confusion above, but I don't understand what case this block is for
| .run()?; | ||
|
|
||
| overlay_unity_meta_skeleton("spacetimedb.bsatn.runtime")?; | ||
| overlay_unity_meta_skeleton("spacetimedb.runtime")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this directory get created for you? for me I only get spacetimedb.bsatn.runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacetimedb.runtime may or may not exist depending on the restore graph; cargo ci dlls currently tries to overlay both, but overlay_unity_meta_skeleton is already a no-op if the package dir doesn’t exist
| @@ -0,0 +1,8 @@ | |||
| fileFormatVersion: 2 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on my system the netstandard2.1 versions get restored, not the net8.0 versions. Is it maybe platform-dependent? Maybe we should copy the net8.0 meta files into a netstandard2.1structure as well, since the code already skips.meta` files for assets that don't exist at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, SpacetimeDB.ClientSDK.csproj references SpacetimeDB.BSATN.Runtime and that package is multi-targeted (netstandard2.1 and net8.0). I don't recall the specifics on if that was because of platform-dependances, but it's plausible to you have a netstandard2.1 artifacts locally. Luckily the overlay copies .meta only for assets that exist, so we shouldn’t need to duplicate net8.0 metas into a netstandard2.1 structure.
bfops
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty great to me. I left some nits, and I think there may be some remaining meta dance to do.
also, I see more files getting restored such as LICENSE and logo.png, so I think we should possibly do what #3648 did and add a gitignore for those files as well.
Updated |
Description of Changes
cargo ci dllssubcommand to build/pack the in-repo C# NuGet packages and the C# SDK.cargo ci dllsrestoressdks/csharp/SpacetimeDB.ClientSDK.csprojusing the freshly built local package outputs as to populatesdks/csharp/packages/**..metaskeleton undersdks/csharp/unity-meta-skeleton~/**and overlays those.metafiles onto the latest restored versioned package directory to keep Unity GUIDs stable and import settings consistent.net8.0, and marking analyzer DLLs with theRoslynAnalyzerlabel so Unity can recognize them).How to use (local)
# Build/pack + restore local packages into sdks/csharp/packages/** cargo ci dllsAPI and ABI breaking changes
N/A
Expected complexity level and risk
2 - Local developer tooling + file overlay into restore output; no runtime/SDK API behavior changes.
Testing
cargo check -p cicargo ci dllsand verified the output undersdks/csharp/packages/**and the various NuGet package locations.