Now that you have a registry and key to upload your packages, let’s create and push a package. I am using here a simple .NET Core class library I wrote to work with CSV files, the source code can be found on GitHub. You can of course use any of your projects.
Problem
How to create and publish NuGet package in .NET Core. Solution
The first setup is to have a registry set up to host the packages, I’ll use nuget.org.
Register a free account at www.nuget.org. Go to “API Keys” section of your account.
Create a new key by giving it a name, scopes (permissions), and selecting packages (* means all).
You’ll see a new key added. Copy the key by clicking on the “Copy” link and paste it somewhere safe.
Now that you have a registry and key to upload your packages, let’s create and publish a package. I am using here a simple .NET Core class library I wrote to work with CSV files, the source code can be found on GitHub. You can, of course, use any of your projects.
Open a Command Prompt in your project directory.
Options used are,
You’ll have the NuGet package created in the publish folder
Run dotnet nuget push command to upload NuGet package to nuget.org.
Browse to your NuGet website and you’ll find your package,
You could also specify other properties in .csproj that adds metadata to your NuGet package, e.g.,
Run dotnet pack command again and open the package in NuGet Package Explorer to view the properites.
For more information on various properties you could set, please see details here.
Pro WPF: Windows Presentation Foundation in .NET 3.0