MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

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

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

Introduction Data preparation is one of the most time-consuming aspects of any data analytics project. It involves collecting, cleaning, transforming, and organizing raw data to ensure it…

Read More

Top 10 AI Low-Code Development Platforms Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI low-code development platforms are transforming how businesses build and deploy AI-driven applications. These platforms empower developers, business analysts, and even non-technical users to…

Read More

Splunk Observability Cloud vs Splunk AppDynamics vs Splunk Cloud Platform

Here’s a clear and updated comparison between Splunk Observability Cloud, Splunk AppDynamics, and Splunk Cloud Platform, highlighting their purpose, strengths, and ideal use cases: 📦 Product Overview…

Read More

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

Introduction Virtualization software is one of the foundational technologies driving the IT landscape in 2026. With the growing demand for cloud computing, IT professionals and businesses are…

Read More

Top 10 Patch Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction: The Importance of Patch Management in 2026 In 2026, as cyber threats evolve and technology becomes more complex, patch management tools are critical for maintaining cybersecurity…

Read More

Top 10 Remote Monitoring & Management (RMM) Tools in 2026: Features, Pros, Cons & Comparison

Introduction In today’s fast-paced, technology-driven world, businesses rely on the seamless functioning of their IT infrastructure. This makes Remote Monitoring & Management (RMM) tools essential for managing,…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Puja kushwaha
Puja kushwaha
20 days ago

Publishing a NuGet package requires more than uploading the file; clear versioning and package details matter too. Before publishing, test the package in a separate project to confirm it installs and works as expected. Keep the README, dependencies, and license information accurate so other developers can use it with confidence. Protect your API key and avoid storing it in source control. These checks help make packages safer to share and easier to maintain.

1
0
Would love your thoughts, please comment.x
()
x