How To Install .Net Core On Ubuntu

This article is your roadmap to install .NET Core on Linux.

  • Install Visual Studio code as a code editor – (skip to step #5 if you already have any kind of code editor)
  • Install .NET core Linux runtime
  • Create/run a basic "hello world" app

.NET Core 2.x is supported on the following Linux 64-bit ( x86_64 or amd64 ) distributions/versions:

  • Red Hat Enterprise Linux 7
  • CentOS 7
  • Oracle Linux 7
  • Fedora 25, Fedora 26
  • Debian 8.7 or later versions
  • Ubuntu 17.04, Ubuntu 16.04 (I have this on my machine), Ubuntu 14.04
  • Linux Mint 18, Linux Mint 17
  • openSUSE 42.2 or later versions
  • SUSE Enterprise Linux (SLES) 12 SP2 or later versions

Step 1 

Download Visual Studio Code deb format as shown in the image below using this here.

.Net Core

Step 2

Open a terminal by clicking this icon, and type terminal.

.Net Core

Step 3

Navigate to the Download directory and install Visual Studio code using these commands.

cd downloads sudo dpkg -i filename.deb
cd downloads
sudo dpkg - i filename . deb 

.Net Core

Step 4

Check if the Visual Studio is installed or not by typing the code in the search bar. You can see that Visual Studio Code is installed.

.Net Core

Step 5

Install curl. For that, open terminal and type the command

sudo apt install curl

Step 6

Register the Microsoft Product key as trusted. Run the following two commands

curl | gpg --dearmor > microsoft.gpg

sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

Step 7

Set up the desired version host package feed. Based on the operating system, run the respective command. I am using Ubuntu 16.04 so I will use the third option – see the command in image below from step#6 and Step#7

Ubuntu 17.10 
sudo sh - c 'echo "deb [arch=amd64] artful main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt - get update
Ubuntu 17.04
sudo sh - c 'echo "deb [arch=amd64] zesty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt - get update
Ubuntu 16.04 / Linux Mint 18
sudo sh - c 'echo "deb [arch=amd64] xenial main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt - get update
Ubuntu 14.04 / Linux Mint 17
sudo sh - c 'echo "deb [arch=amd64] trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt - get update

.Net Core

Step 8

Install.NET Core.

sudo apt-get install dotnet-sdk-2.1.4

Step 9

Check.NET core installed version.

dotnet --version

.Net Core

Step 10

Create a sample console app using CLI command below.

dotnet new console -o hellowordap

.Net Core

Step 11

Let’s run this console app.

.Net Core

cd helloworldapp
dotnet run

Step 12

Open the folder in Visual Studio and you can see program.cs.

.Net Core

.Net Core

Here is good info about When to choose Microsoft .NET Core.

For more details, tutorials, and learning, continue here.