XGain #03 – Publishing .NET Core project to nuget

Packing and publishing nuget from standard .NET project is very simple. Create or generate nuspec file and run

nuget pack

The appearance of the Core framework and project.json file caused the a little change. Due to historical reason, in .NET Core we have two command line interfaces with utilities for packages.

  • DNU – DNX utility, used in project < RC2
  • Dotnet – the newest CLI, combined tool composed of DNX and DNU

Packaging functionality in both tools is very similar. I prefer dotnet cli, because this utility has an one, very important feature – passing suffix version.

Let’s start with demo. XGain is in version 1.0.0 – you can read this from project.json file.

"version": "1.0.0.*"

What about this asterisk? It is a place for a build number. Command which generates a nuget package of XGain in version 1.0.0.1 is really easy

dotnet pack --version-suffix 1

By default, dotnet will compile project with Debug configuration. You can change this by typing

dotnet pack --version-suffix 1 --configuration Release

dotnet pack

Your package is ready, just go to the nuget.org, sign in and publish! 🙂

If you are interested in dotnet pack command, I recommend you Scott’s post, also you can type this command, to get more information.

dotnet pack --help

Just a reminder – XGain available on nuget. You can install this package from nuget package manager or by typing this command in package manager command prompt.

install-package XGain