Table of contents
  1. semantic-release-nuget
    1. Installation
    2. Configuration
    3. Plugin stages
      1. verifyConditions
      2. prepare
      3. publish
    4. Options
    5. Environment variables
    6. Full example

semantic-release-nuget

semantic-release plugin for publishing NuGet packages from .NET projects.

Installation

npm i -D semantic-release-nuget

Configuration

Add the plugin to your .releaserc.json:

{
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    [
      "semantic-release-nuget",
      {
        "nupkgRoot": "./src/MyProject/bin/Release"
      }
    ]
  ]
}

Plugin stages

verifyConditions

Checks that the NUGET_API_KEY environment variable is set before proceeding. The release fails early if the key is absent.

prepare

Packs the .NET project:

dotnet pack [options] /p:Version=<semver>

The semantic version is passed as the Version MSBuild property. No other version properties (VersionSuffix, AssemblyVersion, FileVersion) are set — manage those in the project file if needed.

publish

Pushes the generated .nupkg to the configured NuGet source:

dotnet nuget push *.nupkg

The command runs from the directory specified by nupkgRoot.

Options

Option Required Description
nupkgRoot No Directory containing the .nupkg files produced by prepare. Defaults to the project root.

Environment variables

Variable Required Description
NUGET_API_KEY Yes API key for authenticating with the NuGet source

Full example

{
  "branches": ["main"],
  "plugins": [
    "@semantic-release/commit-analyzer",
    "@semantic-release/release-notes-generator",
    "@semantic-release/changelog",
    [
      "semantic-release-nuget",
      {
        "nupkgRoot": "./src/MyProject/bin/Release"
      }
    ],
    [
      "@semantic-release/git",
      {
        "assets": ["CHANGELOG.md"]
      }
    ]
  ]
}

This site uses Just the Docs, a documentation theme for Jekyll.