Getting .NET Core RC2 Running on Ubuntu for a Complete Linux Novice

NOTE:  There is now a apt-get install 

https://www.microsoft.com/net/core#ubuntu

There is no need to do what is below any longer.


I love the fact that .NET Core lets me code for other platforms. However, because I have been on Windows my entire professional career, most of the documentation for Linux is way over my head.  The help all assumes you are a Linux guru.  This is ironic because if I was that good with Linux I would not be looking for HELP!  So this post is for guys like me that are excited about the opportunities afforded to me by .NET Core but know very little about the world of Linux.  In this post, I will tell you the things most documentation assumes you know.

To begin, we are going to create a Linux machine in Azure so we can get started quickly.  I do assume you know Azure, just not Linux.  It is very important that you create your VM using the correct version of Ubuntu (14.04 LTS). I tried first with a 15.10 version and ran into CoreCLR errors.  From what I could find, only 14.04 is supported at the moment.

  1. From Azure Portal Create 14.04 Ubuntu Linux VM
  2. Connect to your VM (I use putty)

Now that you are connected, you can begin the installation of .NET Core.  However, if you follow the directions here you may get the following errors:

image

I knew enough to know that I was going to have to use apt-get to install the missing tools. The Advanced Package Tool is a free program used to install and remove software on Debian-based Linux distributions, such as Ubuntu.  The frustrating part was that each time I issued the following command to install libunwind, I got an error:

sudo apt-get install libunwind

image

After more searching that I feel was necessary, I learned that the name I was really looking for was libunwind8.  Armed with this information, I was off and running.  All you have to do is issue the following commands. The first command will make sure we have all the updated packages.

sudo apt-get update

Now that we know the correct name, we can install libunwind using the following command:

sudo apt-get install libunwind8

As the original error message mentioned, we also need to install gettext which we can do with the following command:

sudo apt-get install gettext

Now we can follow the directions on the original help page. To install the dotnet command line tools:

curl -sSL https://raw.githubusercontent.com/dotnet/cli/rel/1.0.0/scripts/obtain/dotnet-install.sh | bash /dev/stdin --version 1.0.0-preview1-002702 --install-dir ~/dotnet

Finally we need to create a symbolic link so when we type dotnet at the command line the correct tool is executed.

sudo ln -s ~/dotnet/dotnet /usr/local/bin

Now if you type the following command you should see the default response from dotnet.

dotnet 

image

With the .NET Core in place, we can create our first program. First we need a folder to store our project files.

mkdir helloworld

With the folder created, we need to move into that folder.

cd helloworld

We can use the new command to create a hello world application.

dotnet new

Before we can build the application, we need to download all the dependencies.

dotnet restore

Now we can build the source so we can run our application.

dotnet build

With the build complete, we can now run the application

dotnet bin/Debug/netcoreapp1.0/helloworld.dll

image

There you have it. All you need to get .NET Core RC2 up and running on Linux.

Comments (1) -

Add comment

Loading