Publish nuget packages with .NET Core
Some time ago I posted about publishing your own project Open-Source with GitHub and NuGet: Go open-source with your .NET project. Since then many things happened – but today I want to tell you how to publish to NuGet when you have already tipped your toes into the .NET Core lake. For some recent preparations I built a middleware for ASP.NET Core to proxy calls (mainly for APIs and development) to other hosts and/or endpoints. This can especially be helpful to work around CORS restrictions when you host a SPA and have your API on other servers/ports/endpoints ASP.NET Core might proxy that calls for you. This might bring up some interesting posts about Aurelia and .NET Core but for the moment I want to publish that middleware for everyone.
So let’s go back to my old post. The steps involved creating a .nuspec file. With .NET Core this is no longer necessary, the new generation comes with some awesome command line utilities and a
project.json for all your project configuration tasks. You can create a
.nupkg with a simple
dotnet pack call. With some command line arguments you select the build configuration. But with a minimal
project.json you might miss some of the typical nuget setting. A blog post of Armen Shimoon reveals all the nice details, read it up: Where Does dotnet Get NuGet Package Metadata?
So with that knowledge we just have to add some
tags and maybe others. The rest is up to
dotnet pack -c Release.
Oh, if you would like to take a look at that API proxy middleware, checkout GlacierCrates.AspNetCore.ApiProxy.