Installation Guide

Learn how to install and configure nuget on your system

guide

NuGet is the de‑facto package manager for the .NET ecosystem, and its lightweight command‑line tool, nuget.exe, gives developers fine‑grained control over package operations. This article walks through a straightforward, cross‑platform workflow for installing, configuring, and using nuget.exe, while keeping the tone technical yet approachable.

Prerequisites
• A command‑line shell (PowerShell, CMD, Bash, zsh, etc.) and an active internet connection.
• The .NET SDK or runtime is not required for nuget.exe itself, but it is handy if you plan to build projects that consume packages.

Step 1 – Download nuget.exe

  1. Open a browser and go to https://www.nuget.org/downloads.
  2. Grab the latest nuget.exe binary.
    • Windows: nuget.exe
    • macOS/Linux: nuget.exe (the same file; you can rename it to nuget for convenience)
  3. Place the executable in a directory that is on your system’s PATH. Common choices:
    • Windows: C:\Program Files\NuGet or C:\Tools
    • macOS/Linux: /usr/local/bin or ~/bin
    • After copying, make sure the file is executable on macOS/Linux: chmod +x /usr/local/bin/nuget

Step 2 – Verify the installation
Open a terminal and run:

nuget help

If the help text appears, the tool is reachable and ready to use. On Windows you can also use nuget -? to display help.

Step 3 – Configure global settings
NuGet stores its configuration in a nuget.config file.
• Windows: %APPDATA%\NuGet\NuGet.Config
• macOS/Linux: ~/.config/NuGet/NuGet.Config

You can edit this file to add package sources, set API keys, or tweak other options. For example, to add a custom source:

nuget sources add -Name MyFeed -Source https://myfeed.example.com/nuget/v3/index.json

List current sources with:

nuget sources list

Step 4 – Store API keys for publishing
Keep your NuGet.org API key safe and encrypted in the config file:

nuget setApiKey YOUR_KEY -Source nuget.org

The key is stored in the NuGet.Config file under the section and is only sent to the specified source.

Step 5 – Common commands
• nuget install – downloads a package to the current folder (or to a packages folder if one exists).
• nuget update – updates an existing package.
• nuget restore <solution.sln> – restores all packages for a solution.
• nuget pack <project.csproj> – creates a .nupkg from a project.
• nuget push <package.nupkg> -Source nuget.org – publishes a package.

Step 6 – Using nuget.exe with the .NET SDK
The dotnet CLI already integrates NuGet, so many of the above commands can be replaced with dotnet add package, dotnet restore, etc. However, nuget.exe remains useful for legacy projects, custom scripts, or when you need the full CLI feature set.

Step 7 – Cross‑platform installation shortcuts
On macOS/Linux you can also install NuGet via package managers:
• Homebrew: brew install nuget
• apt (Debian/Ubuntu): sudo apt-get install nuget (may provide an older version)

After installation, make sure the binary is executable:

chmod +x /usr/local/bin/nuget

Step 8 – Troubleshooting tips
• If nuget is not found, double‑check that the directory containing nuget.exe is in the PATH.
• On Windows, restart the shell after adding a new directory to PATH.
• Verify network connectivity if sources cannot be reached; proxy settings can be configured in nuget.config with an http_proxy key.

Step 9 – Security best practices
• Keep nuget.exe up to date to benefit from bug fixes and security patches.
• Store API keys securely; avoid committing them to source control.
• Use signed packages whenever possible to ensure authenticity.

With these steps, you’ll have a robust, cross‑platform NuGet workflow that supports both legacy and modern .NET projects.