Skip to content

NuGet

Uploads packages to NuGet via .NET Core.

Configuration

OptionTypeDescription
workspacesbooleanEnable workspace discovery to auto-generate targets for all packages in the solution
solutionPathstringPath to the solution file (.sln) relative to repo root. Auto-discovers if not specified
includeWorkspacesstringRegex pattern to filter which packages to include. Example: '/^Sentry\./'
excludeWorkspacesstringRegex pattern to filter which packages to exclude. Example: '/\.Tests$/'
artifactTemplatestringTemplate for artifact filenames. Variables: {{packageId}}, {{version}}
serverUrlstringNuGet server URL. Default: https://api.nuget.org/v3/index.json

Workspace Support

When workspaces: true is enabled, Craft will automatically:

  1. Parse the solution file (.sln) to discover all projects
  2. Parse each .csproj file to extract package IDs and dependencies
  3. Sort packages topologically so dependencies are published before dependents
  4. Expand the single nuget target into multiple individual targets (one per package)
  5. Publish packages sequentially in the correct order

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

Environment Variables

NameDescription
NUGET_API_TOKENNuGet API token
NUGET_DOTNET_BINPath to .NET Core. Default: dotnet

Examples

Basic Usage

Publishes all .nupkg artifacts found:

targets:
- name: nuget

Workspace Discovery

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

targets:
- name: nuget
workspaces: true

Workspace with Filtering

Publish only packages matching a pattern, excluding test packages:

targets:
- name: nuget
workspaces: true
solutionPath: src/Sentry.sln
includeWorkspaces: '/^Sentry\./'
excludeWorkspaces: '/\.Tests$/'

Custom Artifact Template

Use a custom artifact filename pattern:

targets:
- name: nuget
workspaces: true
artifactTemplate: 'packages/{{packageId}}.{{version}}.nupkg'