NuGet
Uploads packages to NuGet via .NET Core.
Configuration
| 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 (.sln) relative to repo root. Auto-discovers if not specified |
includeWorkspaces | string | Regex pattern to filter which packages to include. Example: '/^Sentry\./' |
excludeWorkspaces | string | Regex pattern to filter which packages to exclude. Example: '/\.Tests$/' |
artifactTemplate | string | Template for artifact filenames. Variables: {{packageId}}, {{version}} |
serverUrl | string | NuGet server URL. Default: https://api.nuget.org/v3/index.json |
Workspace Support
When workspaces: true is enabled, Craft will automatically:
- Parse the solution file (
.sln) to discover all projects - Parse each
.csprojfile to extract package IDs and dependencies - Sort packages topologically so dependencies are published before dependents
- Expand the single nuget target into multiple individual targets (one per package)
- Publish packages sequentially in the correct order
This is useful for monorepos with multiple NuGet packages that depend on each other.
Environment Variables
| Name | Description |
|---|---|
NUGET_API_TOKEN | NuGet API token |
NUGET_DOTNET_BIN | Path to .NET Core. Default: dotnet |
Examples
Basic Usage
Publishes all .nupkg artifacts found:
targets: - name: nugetWorkspace Discovery
Automatically discovers and publishes all packages from a solution file in dependency order:
targets: - name: nuget workspaces: trueWorkspace 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'