A NuGet release pipeline should do more than build a project and upload a .nupkg file.

For shared libraries, the package can be used by many applications immediately after publication. A small mistake in the package, dependency configuration, versioning, or release notes can therefore create problems for multiple teams.

A human approval step provides a controlled point between automated validation and public release.

The goal is not to make developers manually perform the release. The goal is to let automation prepare and validate the package while a maintainer makes the final release decision.

A practical workflow looks like this:

Code
Commit
  |
  v
Build
  |
  v
Unit Tests
  |
  v
Create NuGet Package
  |
  v
Package Validation
  |
  v
Publish to Staging Feed
  |
  v
Integration / Consumer Tests
  |
  v
Human Approval
  |
  v
Publish to Public Feed

Why Add Human Approval to a NuGet Pipeline?

Fully automated releases are useful, but not every release should automatically become public.

Consider a shared library with several consuming applications. The automated tests may pass, but the release may still require review because:

  • A public API changed.

  • A dependency was upgraded.

  • A breaking behavior was introduced.

  • Release notes need correction.

  • The package version does not match the intended change.

  • Integration testing exposed a compatibility issue.

  • The release is being prepared but should not become public yet.

The approval stage gives a maintainer a chance to review the release without manually building or uploading anything.

Automation handles the repetitive work. The human controls the final decision.

Separate Build, Validation, and Release

A common mistake is to combine everything into one pipeline job:

Code
script:
  - dotnet build
  - dotnet test
  - dotnet pack
  - dotnet nuget push

This creates a direct path from source code to public package publication.

A better design separates the stages:

Code
Build
  |
Test
  |
Pack
  |
Validate
  |
Stage
  |
Approve
  |
Release

Each stage has a different responsibility.

Stage

Responsibility

Build

Compile the application or library

Test

Run automated tests

Pack

Create the NuGet artifact

Validate

Check package contents and metadata

Stage

Publish to an internal feed

Approve

Review the release

Release

Publish the approved artifact

This separation also makes pipeline failures easier to understand.

Build the Package Once

One of the most important rules in a release pipeline is to create the package once and reuse that artifact.

For example:

SQL
dotnet restore

dotnet build \
  --configuration Release \
  --no-restore

dotnet test \
  --configuration Release \
  --no-build

dotnet pack \
  --configuration Release \
  --no-build \
  --output ./artifacts

The generated package should then be stored as a pipeline artifact.

For example:

Code
artifacts/
    MyLibrary.3.1.0.nupkg
    MyLibrary.3.1.0.snupkg

The later stages should consume these files.

Do not rebuild the package after approval.

If the pipeline builds the package again, the artifact that was tested may not be exactly the same artifact that is published.

Validate the NuGet Package

A successful project build does not guarantee a correct NuGet package.

The validation stage should inspect the package before it reaches the staging feed.

For example:

Code
dotnet nuget verify ./artifacts/MyLibrary.3.1.0.nupkg

You can also inspect the package contents:

Code
unzip -l ./artifacts/MyLibrary.3.1.0.nupkg

Check that the package contains the expected assemblies, dependency metadata, and target framework directories.

For example:

Code
lib/
    net8.0/
    netstandard2.0/

[Content_Types].xml
MyLibrary.nuspec

The exact structure depends on the package.

The important point is that package validation should happen before public publication.

Publish to a Staging Feed

The next stage should publish the package to a private NuGet feed.

For example:

Bash
dotnet nuget push ./artifacts/MyLibrary.3.1.0.nupkg \
  --source "$STAGING_FEED" \
  --api-key "$STAGING_API_KEY"

The staging feed allows the package to be tested using the same package installation process that consumers will use.

This is better than testing only with a project reference.

Test the Package From a Consumer Application

A simple consumer project can detect packaging problems that library tests may miss.

Create a temporary application:

Code
dotnet new console -n PackageConsumerTest
cd PackageConsumerTest

Install the staged package:

Code
dotnet add package MyLibrary \
  --version 3.1.0 \
  --source "$STAGING_FEED"

Then build and run the application:

Code
dotnet restore
dotnet build
dotnet run

This verifies that the package can actually be restored and used as a dependency.

For important libraries, the consumer test can go further.

It can verify:

  • Public API compatibility

  • Runtime behavior

  • Dependency resolution

  • Configuration requirements

  • Serialization behavior

  • Integration with another service

  • Multiple target frameworks

Introduce the Approval Gate

Once automated validation completes successfully, the pipeline should stop before public publication.

The release stage can be protected by an approval rule.

Conceptually:

Code
Validation Passed
      |
      v
[ Waiting for Approval ]
      |
   +--+--+
   |     |
Approve Reject
   |     |
   v     v
Release Stop

The approver should be someone responsible for the package rather than simply the person who triggered the pipeline.

Depending on the organization, this could be:

  • Library maintainer

  • Platform team member

  • Release manager

  • Engineering lead

The approval should not require access to the NuGet credentials.

The approver only decides whether the already validated artifact should be released.

What Should the Approver Check?

The approval step should be based on useful information rather than simply displaying a button.

Before approving, review:

Code
Package: MyLibrary
Version: 3.1.0

Build: Passed
Unit Tests: Passed
Package Validation: Passed
Staging Publish: Passed
Consumer Tests: Passed

API Changes: Reviewed
Dependencies: Reviewed
Release Notes: Ready

The exact information depends on the CI/CD platform, but the principle is the same.

The person approving the release should understand what is being published and why.

Protect Production Credentials

The public NuGet API key should only be available to the release stage.

Do not expose it to build or test jobs.

Avoid this:

Code
env:
  NUGET_API_KEY: "actual-secret-value"

Use the CI/CD platform's secret-management system instead.

The release command can then reference the secret:

Bash
dotnet nuget push ./artifacts/*.nupkg \
  --source "$NUGET_FEED" \
  --api-key "$NUGET_API_KEY"

This provides an important security boundary.

Even if a normal test job is compromised, it does not automatically have permission to publish packages publicly.

Keep Release and Build Permissions Separate

A useful permission model looks like this:

Pipeline stage

Public NuGet permission

Build

No

Unit tests

No

Package validation

No

Staging publish

No

Approval

No

Production release

Yes

This follows the principle of least privilege.

Only the job that needs to publish publicly should receive the production credential.

Handle Rejected Releases

A release should not become difficult to recover from when an approver rejects it.

For example:

Code
3.1.0
  |
  +-- Rejected
       |
       v
Fix
  |
  v
3.1.1

If the package needs code changes, create a new commit and run the pipeline again.

If the problem is only release timing, the same validated artifact can remain in staging until the release is approved, depending on the retention and package policies of the feed.

Do not modify the package after it has passed validation.

Avoid Rebuilding After Approval

This is a subtle but important pipeline problem.

Consider this process:

Code
Build package A
    |
Test package A
    |
Approve
    |
Build package B
    |
Publish package B

The approval was actually given to package A, but package B was published.

That creates an integrity problem.

The safer flow is:

Code
Build package A
    |
Test package A
    |
Approve package A
    |
Publish package A

The artifact should remain unchanged throughout the pipeline.

Example Pipeline Structure

The exact syntax differs between GitHub Actions, Azure DevOps, GitLab CI, and other platforms, but the logical structure can remain consistent.

For example:

Code
stages:
  - build
  - validate
  - staging
  - release

The build stage creates the artifact:

Code
build:
  script:
    - dotnet restore
    - dotnet build --configuration Release
    - dotnet test --configuration Release
    - dotnet pack --configuration Release --output artifacts

The validation stage checks it:

Code
validate:
  script:
    - dotnet nuget verify artifacts/*.nupkg

The staging stage publishes it internally:

Code
staging:
  script:
    - dotnet nuget push artifacts/*.nupkg \
        --source "$STAGING_FEED" \
        --api-key "$STAGING_API_KEY"

The release stage is protected by the CI/CD platform's approval mechanism:

Code
release:
  script:
    - dotnet nuget push artifacts/*.nupkg \
        --source "$NUGET_FEED" \
        --api-key "$NUGET_API_KEY"

The important part is not the specific YAML syntax. It is the dependency between stages.

The release job should not run until the approval requirement has been satisfied.

Common Mistakes

Putting Approval After Public Publication

The approval must happen before the production push.

An approval after publication does not provide release protection.

Building Again in the Release Stage

Use the stored artifact from the earlier stages.

Do not run dotnet pack again.

Giving Every Job the Production API Key

Only the production release job should have access to the public feed credentials.

Making Approval a Formality

An approval step is useful only when the approver has enough information to make a decision.

Display test results, package version, API changes, and release information.

Testing Only the Source Project

Always test the package itself when package correctness matters.

Using Mutable Package Versions

Treat released package versions as immutable.

If a problem is found, publish a new version.

Best Practices

Practice

Recommendation

Artifact

Build the NuGet package once

Validation

Validate the actual .nupkg

Testing

Test through a consumer project

Staging

Use a private package feed

Approval

Require approval before public release

Credentials

Keep production keys restricted

Versioning

Never replace an existing released version

Release

Publish the exact approved artifact

Audit

Keep pipeline and approval records

Another useful practice is to make the release pipeline boring.

A good release pipeline should not depend on someone manually copying files, changing configuration, or running commands from a developer workstation.

Once the package has been approved, the final publication should be predictable.

Advantages

A human approval step provides a useful control without turning the entire release process into manual work.

The main advantages are:

  • Automated testing remains fast.

  • Public publication requires an explicit decision.

  • Production credentials can be isolated.

  • The exact tested artifact can be released.

  • Release history becomes easier to audit.

  • High-risk changes receive additional review.

This is particularly useful for libraries consumed by multiple teams or applications.

Disadvantages

There are trade-offs.

A manual approval can slow down small releases, especially when the approver is unavailable.

The pipeline also requires more configuration than a simple build-and-push workflow.

For low-risk internal packages, automatic publication may be reasonable. For widely consumed libraries, the additional control can provide better protection.

Troubleshooting

Approval Is Not Appearing

Check that the release environment or deployment stage actually requires approval.

Also verify that the configured approver has the required permissions.

Release Job Cannot Find the Package

Check that the build artifact is being transferred between pipeline stages.

The release job should use the same .nupkg generated during the build.

Package Exists in Staging but Cannot Be Published

Verify the production feed URL, credentials, package version, and feed permissions.

Approval Succeeded but the Wrong Package Was Published

Check whether the release stage rebuilds the project.

If it does, change the pipeline so the release stage consumes the stored artifact instead.

Summary

A NuGet release pipeline should separate automation from release authority.

The pipeline can automatically build, test, validate, and stage the package. A human approval step can then provide the final decision before public publication.

A reliable workflow looks like this:

Code
Commit
  -> Build
  -> Test
  -> Pack
  -> Validate
  -> Staging Feed
  -> Consumer Tests
  -> Human Approval
  -> Public NuGet Feed

The most important rule is to publish the exact artifact that was tested and approved. Do not rebuild it after approval, and do not give production package credentials to unrelated pipeline stages.

This design keeps the release process automated while adding a clear control point before a package reaches its consumers.