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 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
  • Pingback: dotnetomaniak.pl()

  • I’ve been wondering how this works with regard to dependencies. Are dependent packages added nuget dependencies automatically? And how does it behave when you have multiple projects within a solution? Are they packaged and referenced correctly in nupkgs?

    • Unfortunately, there is a problem with dependencies – they are not copied to the nupgk. This “feature” will be available in the RTM version.”
      In Kronos project I have three project – Client, Server and one shared library – Core. After few hours of investigation how to publish Client with Core, I’ve decided to publish Core as a separated nuget package. That is probably the easiest way to work with dependencies until RTM release 🙂