How to Publish a NuGet Package
Command line
To push packages to nuget.org you must use nuget.exe v4.1.0 or above, which implements the required NuGet protocols. You also need an API key, which is created on nuget.org.
Create API keys
-
Sign into your nuget.org account or create an account if you don't have one already.
For more information on creating your account, see Individual accounts.
-
Select your user name (on the upper right), then select API Keys.
-
Select Create, provide a name for your key, select Select Scopes > Push. Enter * for Glob pattern, then select Create. (See below for more about scopes.)
-
Once the key is created, select Copy to retrieve the access key you need in the CLI:
-
Important: Save your key in a secure location because you cannot copy the key again later on. If you return to the API key page, you need to regenerate the key to copy it. You can also remove the API key if you no longer want to push packages via the CLI.
Scoping allows you to create separate API keys for different purposes. Each key has its expiration timeframe and can be scoped to specific packages (or glob patterns). Each key is also scoped to specific operations: push of new packages and updates, push of updates only, or delisting. Through scoping, you can create API keys for different people who manage packages for your organization such that they have only the permissions they need. For more information, see scoped API keys.
Publish with nuget push
-
At a command prompt, run the following command, replacing
<your_API_key>
with the key obtained from nuget.org:cli
-
nuget setApiKey <your_API_key>
This command stores your API key in your NuGet configuration so that you need repeat this step again on the same computer.
-
Push your package to NuGet Gallery using the following command:
cli
nuget push YourPackage.nupkg -Source https://api.nuget.org/v3/index.json