Repository navigation
feat(nuget)!: Add workspaces support for dependency-ordered publishing - #686
Conversation
- Add automatic discovery of NuGet packages from .sln/.csproj files - Topologically sort packages by dependencies for correct publish order - Change from parallel (Promise.all) to sequential publishing - Remove --skip-duplicate flag (no longer needed with proper ordering) - Add workspace config options: workspaces, solutionPath, includeWorkspaces, excludeWorkspaces, artifactTemplate - Security: All discovery uses static file parsing only (no code execution) Closes #649
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
|
…tPattern Refactor escapeRegex helper to top-level function and use it in packageIdToNugetArtifactPattern to properly escape all regex meta-characters, not just dots.
…pattern - Export escapeRegex from workspaces.ts for reuse - Fix packageNameToArtifactPattern to escape all regex special chars - Use shared escapeRegex in dotnetWorkspaces.ts and powershell.ts
Instead of fully sequential publishing, use p-limit to allow up to 3 concurrent package uploads. This provides a good balance between speed and avoiding overwhelming NuGet.org.
|
hey @BYK , thanks for looking at improving the nuget upload experience. Uploading things in order is probably an improvement (though processing the packages happen async so not sure nuget.org will actually process them in order too) Did you try this out with our SDK? Some things worth noting: Our SDK doesn't only rely on Wrt parsing .sln, note that there's a .slnx file now and we plan (should at least) to migrate over to it eventually once tooling is more mature around it. One other thing is that we have solution filters in the repo, which we use to develop different parts (Mobile vs Web etc) but I don't think this will affect craft or your PR. But worth mentioning for context. Lastly and this might affect this PR is that we output not only nupkg but also snupkg files, which contain the debug symbols. But if at the end of the day it's judt running Hope this context helps. Lets hear from @Flash0ver who is the maintainer of .NET he might have other/more context here. |
- Artifact patterns now match both .nupkg and .snupkg (symbol packages) - Add .slnx (XML-based solution) file format support - Add explicit tests for escapeRegex backslash handling - Prefer .slnx over .sln when both exist
|
@bruno-garcia thanks a lot for the great feedback! I'm just vibe coding this to get the ball rolling. Fed your feedback to Cursor and it did some more things: f0be729 I'll wait for @Flash0ver's review and tests on the SDK repo as this is being done mostly for our own SDK :) |
We have moved over to slnx now - it's a way simpler format than the old sln files so hopefully that makes things easier. |
# Conflicts: # package.json # src/targets/nuget.ts # src/targets/powershell.ts # yarn.lock Co-Authored-By: Burak Yigit Kaya <[email protected]>
…iscovery - Find projects nested in slnx <Folder> elements (Sentry.slnx layout) - Inherit IsPackable/PackageId from Directory.Build.props and its static imports - Ignore conditional or property-dependent MSBuild values - Collect ProjectReference deps from imported .props/.targets regardless of conditions, and map project names to PackageIds - Never push .snupkg files on their own when includeNames matches both Co-Authored-By: Burak Yigit Kaya <[email protected]>
ric-oliv
left a comment
There was a problem hiding this comment.
Thanks for picking this up!
I tested the discovery against the current sentry-dotnet repo (Sentry.slnx, 98 projects). With the filters from the docs example, it expands to exactly the 23 packages we ship, in a sensible order.
What blocks this for me is that the PR also changes the default (non-workspace) path. sentry-dotnet uses that path today with a plain - name: nuget. getsentry/publish runs getsentry/craft:latest, so these changes would hit our next release without any config change:
- --skip-duplicate is removed, so retrying a partially failed publish fails on the first package that's already on nuget.org (409)
Before merging, I'd like to see:
- Keep --skip-duplicate.
- Drop the pLimit change from this PR, unless we hit rate limiting on NuGet.org.
- Fail instead of warning when workspaces: true finds no packages.
- Remove artifactTemplate from the nuget target.
- Update the PR description. It still says forEachChained, and the example uses src/Sentry.sln.
- Drop the p-limit upload concurrency; keep master's Promise.all - Throw ConfigurationError when workspace discovery (nuget and npm) finds no packages or filters remove all of them - Remove nuget artifactTemplate: it couldn't match path-style names and silently dropped .snupkg files - Document that skipped packages aren't published and to check `craft targets` Co-Authored-By: byk <[email protected]>
Before pushing a .nupkg, check whether the version is already on the feed. If it is, download the published package and compare every file (SHA-256, ignoring the .signature.p7s the server adds). Identical packages are not pushed again; only a missing .snupkg is pushed, which is checked on nuget.org's symbol CDN. A different package under the same version fails the target. If the state can't be determined, the .nupkg is pushed as before so a duplicate still fails loudly. Co-Authored-By: Burak Yigit Kaya <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit cf6df6f. Configure here.
ric-oliv
left a comment
There was a problem hiding this comment.
Thanks for adding the recovery! I tested it against sentry-dotnet. craft targets still expands our config to exactly the packages we ship, and the new check returns identical against nuget.org for all 23 packages of 7.0.0-rc.2. So a retry would skip those and only push a .snupkg that's missing.
One thing before merging. The description's breaking-change section still says an existing version fails "because Craft can't verify that the existing package matches the one it's publishing". It can now. Could you update it to describe what a retry does, like the new "Retrying a Partial Publish" section in the docs? That way anyone reading about the breaking change also sees how to recover.
Craft's nuget target is dropping --skip-duplicate (getsentry/craft#686). With our single nuget target, a retry after a partly failed publish would stop at the first package that's already on nuget.org. With workspaces enabled, craft splits the target into one target per package, in dependency order, and a retry skips the packages that already went out. Craft releases without workspace support pass the new keys through and keep publishing everything as one target, so this is safe to merge before the craft release. Co-authored-by: Claude Opus 5.5 <[email protected]>

Adds
workspaces: trueto the NuGet target. Craft discovers the .NET packages in a solution, sorts them by their project dependencies, and expands the singlenugettarget into one target per package, published in dependency order.Closes #649
Breaking change
The nuget target no longer passes
--skip-duplicatetodotnet nuget push, including the default non-workspace path. Craft no longer skips an existing version blindly. Before each push it checks what the feed already has, so a retry only skips packages it has verified are identical, and fails on anything else:.nupkg;dotnet nuget pushsends the.snupkgnext to it right after..nupkgagain. Craft downloads the published copy from the feed'sPackageBaseAddress(flat container) and compares the SHA-256 of every file with the local package. It ignores.signature.p7s, which nuget.org adds when it repository-signs the package. If there's a local.snupkgand nuget.org's symbol CDN (globalcdn.nuget.org/symbol-packages/…) doesn't have it, only the.snupkgis pushed..nupkgas before, so an existing version still fails the push.To recover from a partial publish, rerun the target. For example, if a
.nupkgwas uploaded but its.snupkgwasn't, the rerun uploads just the symbols, with no manualnuget push. Limits:.snupkgis pushed again and the server decides whether to accept it.With workspaces enabled, each package is its own target in the publish state, so a rerun only retries the packages that failed. Projects that publish many packages through a plain
- name: nugettarget should switch toworkspaces: true.workspaces: trueon the npm target now also fails with a configuration error when no publishable packages are found, instead of warning and skipping the target.How discovery works
Discovery only parses files statically. It never runs MSBuild or any code from the target repo.
.slnx(preferred) or.sln, including projects nested in.slnx<Folder>elements.PackageIdandIsPackablefrom each.csprojand from the nearestDirectory.Build.props, following imports with static paths. Values with aConditionor a$(...)reference are ignored, andIsPackabledefaults totrue.ProjectReferencedependencies from the project and from statically imported.props/.targetsfiles, regardless of conditions. Platform-specific dependencies, such as Sentry's Android and Cocoa bindings, are still published first.includeWorkspaces/excludeWorkspacesremove all of them.Against sentry-dotnet's
Sentry.slnx, the config below expands to exactly the packages it ships, in a valid order.Other changes
.nupkgand.snupkg.publishsplits artifacts by extension, so a.snupkgis pushed together with its.nupkg, or on its own only when that.nupkgis already published with identical contents.escapeRegexis now shared by the npm, NuGet and PowerShell artifact patterns, and it escapes all regex special characters.Example
Run
craft targetsafter changing the solution or the filters to check the expanded list. A package that discovery skips is simply not published.via byk.
--
View Junior Session [Sentry]