Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

“Invest in yourself — your confidence is always worth it.”

Explore Cosmetic Hospitals

Start your journey today — compare options in one place.

Publish NuGet Packages to NuGet.org: CLI Steps, Workflow, and CI Example

Originally published on 2015-11-21; fully revised and updated.

This guide shows how to publish a .nupkg file to NuGet.org from the command line. It is aimed at .NET developers and DevOps engineers who need a clear manual process and a simple path to automation.

publish-a-nuget-package-in-nuget-gallery

What you need before publishing

  • A NuGet.org account at nuget.org.
  • An API key generated from your NuGet.org account settings.
  • A package file ending in .nupkg (built from your project).
  • Either nuget.exe or the dotnet CLI installed on the machine that will publish.

NuGet publishing workflow

flowchart TD
    A[Create NuGet account] --> B[Generate API key]
    B --> C[Build and pack project]
    C --> D[Prepare publish command]
    D --> E[Push nupkg to nuget.org]
    E --> F{Accepted by feed}
    F -- yes --> G[Install by package id and version]
    F -- no --> H[Fix metadata or version]
    H --> C

Publish with nuget.exe (classic CLI)

The original post used nuget.exe. The same core flow still applies: store an API key, then push the package.

Step 1: Store your API key on this machine

nuget setApiKey YOUR_NUGET_API_KEY

This saves the key locally so you do not need to provide it every time on the same machine.

Step 2: Push the package

nuget push YourPackage.nupkg -Source https://api.nuget.org/v3/index.jsonCode language: JavaScript (javascript)

Publish with dotnet CLI (cross-platform)

If your build already uses the .NET SDK, you can publish with dotnet nuget push and pass the API key directly.

dotnet nuget push ./artifacts/YourPackage.1.0.0.nupkg --source https://api.nuget.org/v3/index.json --api-key YOUR_NUGET_API_KEYCode language: JavaScript (javascript)

nuget.exe vs dotnet CLI

OptionTypical push commandBest forNotes
nuget.exenuget push YourPackage.nupkg -Source https://api.nuget.org/v3/index.jsonTeams already using NuGet CLI workflowsCan store API key once with nuget setApiKey.
dotnet CLIdotnet nuget push ... --source https://api.nuget.org/v3/index.json --api-key ...SDK-style .NET projects and cross-platform CIFits naturally into dotnet-based build pipelines.

CI-friendly example

This example packs a project and publishes all generated packages. The API key is read from an environment variable (for example, from your CI secret store).

#!/usr/bin/env bash
set -euo pipefail

dotnet pack ./src/MyLibrary/MyLibrary.csproj -c Release -o ./artifacts

dotnet nuget push "./artifacts/*.nupkg" \
  --source "https://api.nuget.org/v3/index.json" \
  --api-key "$NUGET_API_KEY"Code language: PHP (php)

Verify the package after publishing

After publish completes, verify consumers can resolve the package and version from NuGet.org.

dotnet add package YourPackage --version 1.0.0Code language: CSS (css)

Reference

Original reference from the post: https://docs.nuget.org/consume/command-line-reference

Best practices

  • Use a new package version for each release.
  • Keep API keys in a secret manager; do not commit them to source control.
  • Use the explicit NuGet.org source URL in automation for predictable behavior.
  • Perform a quick install test after publish to confirm package availability.

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
I'm Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms. I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.

Related Posts

The Main Challenges of Metaverse Game Development

The news about tech giants investing in metaverse development ignited a lot of discussions about its potential use cases. GameDev has turned up at the forefront of…

Read More

Top 10 AI Data Integration Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI data integration tools are pivotal for businesses navigating the complexities of modern data ecosystems. These tools combine artificial intelligence with data integration processes…

Read More

Top 10 Presentation Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, creating engaging and impactful presentations is more than just slides with bullet points—it’s about telling a story, conveying ideas visually, and keeping your audience…

Read More

Top 10 AI Ad Copy Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI ad copy tools have become indispensable for marketers, businesses, and content creators aiming to craft compelling, high-converting advertisements at scale. These tools leverage…

Read More

Top 10 Enterprise Resource Planning (ERP) Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, Enterprise Resource Planning (ERP) software is more vital than ever for organizations that seek to streamline their operations, improve efficiency, and make data-driven decisions….

Read More

Top 10 Job Costing Software Tools in 2026: Features, Pros, Cons & Comparison

Introduction Job costing software is a vital tool for businesses, especially in industries like construction, manufacturing, and services, where accurately tracking the costs associated with individual projects…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
1
0
Would love your thoughts, please comment.x
()
x