Getting .NET CLI working on Linux

While it’s awesome that .NET is coming to Linux, sometimes it seems to be coming quite slowly. I’m like an impatient infant waiting for a biscuit here: I want it now now now NOW.

Currently, the properly bleeding edge .NET Core Command Line Interface is only supported on Ubuntu 14.04 and CentOS 7.1. I tried to get it working on my Arch installation, but no dice.

Since I’d done something horrible to the filesystem that Arch was installed on and needed to re-install anyway, I decided I’d use Ubuntu 14.04 for a bit, until more distros are supported. I’ve actually installed Linux Mint, which looks about the same since I was using the Cinnamon desktop on Arch anyway.

OK, I’m running an officially supported distro now, so I head over to and follow the Ubuntu instructions, which are the usual "add an APT feed and install from that".

The adding a feed bit works:

$ sudo sh -c 'echo "deb [arch=amd64] trusty main" > /etc/apt/sources.list.d/dotnetdev.list'

$ sudo apt-key adv --keyserver --recv-keys 417A0893

$ sudo apt-get update

But the next instruction failed:

$ sudo apt-get install dotnet
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package dotnet is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'dotnet' has no installation candidate

OK. Hunting around, I use apt-cache search to find all packages with dotnet in the name:

$ apt-cache search dotnet
dotnet-nightly - Unstable Developer Build of .NET Core & command line tools
dotnet-dev - .NET Core & command line tools
testpackage-dotnet - Test Package
libgtk2.0-cil - CLI binding for the GTK+ toolkit 2.12
libgtk2.0-cil-dev - CLI binding for the GTK+ toolkit 2.12
libgtk-dotnet3.0-cil - GTK.NET library
libgtk-dotnet3.0-cil-dev - GTK.NET library - development files

This looks promising-ish; there are two dotnet packages there. Being on the more conservative end of the rabidly impatient spectrum, I decided to go for dotnet-dev, which was wrong. I did my dotnet new, and that was fine, and then I did my dotnet restore and that was OK too, but when I did dotnet run I got told

$ dotnet run
Could not resolve coreclr path

Which took me to this StackOverflow question, so I uninstalled dotnet-dev and installed dotnet-nightly.

And the same thing happened, which led me past the first Google result and to this GitHub issue, which told me that the workaround was to run:

$ sudo ln -s /usr/share/dotnet-nightly /usr/share/dotnet

Except I already had a dotnet directory in /usr/share (from the abortive dotnet-dev installation, perhaps?), so I had to remove that before running the ln again.

And now, finally, everything works.

Of course, this being Microsoft 2016, the .NET Core web site is open source and hosted in GitHub Pages, so I’ve sent in a PR with updated instructions.


This post might sound a little complainy, so I’d just like to add that the work that is being done on .NET Core and all its associated bits is absolutely bloody wonderful, and I have nothing but respect for the people doing it. I seriously cannot wait for the day when I can use C# to create native binaries for all platforms (and I have my fingers crossed for dead code elimination).

Share on facebook
Share on google
Share on twitter
Share on linkedin


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.