Skip to content

NuGet

Uploads packages to NuGet via .NET Core.

Option Type Description
workspaces boolean Enable workspace discovery to auto-generate targets for all packages in the solution
solutionPath string Path to the solution file (.slnx or .sln) relative to repo root. Auto-discovers if not specified, preferring .slnx
includeWorkspaces string Regex pattern to filter which packages to include. Example: '/^Sentry\./'
excludeWorkspaces string Regex pattern to filter which packages to exclude. Example: '/\.Tests$/'
serverUrl string NuGet server URL. Default: https://api.nuget.org/v3/index.json

When workspaces: true is enabled, Craft will automatically:

  1. Parse the solution file (.slnx or .sln) to discover all projects, including projects nested in solution folders
  2. Parse each .csproj file to extract package IDs and dependencies
  3. Skip projects that are not packable (<IsPackable>false</IsPackable>)
  4. Sort packages topologically so dependencies are published before dependents
  5. Expand the single nuget target into multiple individual targets (one per package)
  6. Publish packages sequentially in the correct order

Each package’s .snupkg symbol package, if present, is pushed together with its .nupkg.

This is useful for monorepos with multiple NuGet packages that depend on each other.

If workspaces: true is set but discovery finds no packages, or the filters exclude all of them, Craft fails with a configuration error instead of skipping the target.

Craft does not pass --skip-duplicate to dotnet nuget push: pushing a version that already exists fails, because Craft can’t otherwise tell whether the existing package is the one it’s trying to publish.

Instead, before pushing each .nupkg, Craft checks whether the server already has that version:

  • Not published: the .nupkg is pushed, and dotnet nuget push pushes the .snupkg next to it right after.
  • Published with identical contents: the .nupkg is not pushed again. Craft downloads the published package from the feed’s PackageBaseAddress and compares every file in it with the local package, ignoring .signature.p7s (the repository signature the server adds). If there is a .snupkg and the server doesn’t have it yet, only the .snupkg is pushed.
  • Published with different contents: the target fails. NuGet versions are immutable, so publish a new version instead.

This lets you retry a release that failed halfway, for example when the .nupkg was uploaded but its .snupkg wasn’t, by rerunning the target, instead of someone pushing the missing file by hand.

Name Description
NUGET_API_TOKEN NuGet API token
NUGET_DOTNET_BIN Path to .NET Core. Default: dotnet

Publishes all .nupkg artifacts found:

targets:
- name: nuget

Automatically discovers and publishes all packages from a solution file in dependency order:

targets:
- name: nuget
workspaces: true

Publish only packages matching a pattern, excluding packable test apps:

targets:
- name: nuget
workspaces: true
solutionPath: Sentry.slnx
includeWorkspaces: '/^Sentry/'
excludeWorkspaces: '/(TrimTest|CrashableApp)$/'