DEV Community 👩‍💻👨‍💻

Cover image for Installing DotNet Core in Ubuntu 18.04
Carlos Fabara
Carlos Fabara

Posted on • Updated on

Installing DotNet Core in Ubuntu 18.04


Since the time this article was published Microsoft has released the official way of installing DotNet Core you can find them in DotNet Ubuntu 18.04 Downloads

With the release of Ubuntu 18.04 the new LTS version of the popular Operating System, people might be eager to try dotnet on the platform.

Sadly, at the time of writing this post, neither the page getting stater page DotNet Get Stated nor the downloads page DotNet Downloads list a compatible package with this OS.

In fact, if you try to install following the instruccions for the closest release which was 17.04 Instructions Ubuntu 17.04 you will get an error of missing dependencies.

In order to install you have to used the following steps as it is indicated in this GitHub issue.

Registering Microsoft keys and feeds

It is necessary to add the keys and the feed to the system so you have to type in a terminal the following commands.

sudo apt-key adv --keyserver --recv-keys EB3E94ADBE1229CF

sudo apt-key adv --keyserver --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893
Enter fullscreen mode Exit fullscreen mode

To add the feed you need to type:

sudo sh -c 'echo "deb [arch=amd64] bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
Enter fullscreen mode Exit fullscreen mode

And update the packages list with

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

Installing DotNet Core

To install dotnet you can use the stable version with:

sudo apt-get install dotnet-sdk-2.1.105 
Enter fullscreen mode Exit fullscreen mode

Or the newest preview version with:

sudo apt install dotnet-sdk-2.1.300-preview2-008533
Enter fullscreen mode Exit fullscreen mode

Remember that you can have both installed side by side, newer dotnet have the dotnet --list-sdks and dotnet --list-runtimes, although the newest will be used if it is not overridden with a global.json file. You can find more info in this Scott Hanselman's post. Also

Testing the installation

Inside a folder create a new console project with:

dotnet new console
Enter fullscreen mode Exit fullscreen mode

To run it, you need to use:

dotnet run
Enter fullscreen mode Exit fullscreen mode

And everything works correctly qou will be able to see a Hello World message on your terminal:

Hello World!
Enter fullscreen mode Exit fullscreen mode

Top comments (9)

thiennn2 profile image

Can u help me?

➜  ~ dotnet run  
/usr/share/dotnet/sdk/2.1.300-preview2-008533/Microsoft.Common.CurrentVersion.targets(3045,5): error MSB3552: Resource file "**/*.resx" cannot be found. [/home/thienmta/thienmta.csproj]

The build failed. Please fix the build errors and run again.
maskezen profile image
Diego Mascheroni

How to trust the self signed certificate to run a web app on https?

since dotnet dev-certs https --trust not work in linux.

twotwentyfour profile image

Hours I've spent working on this. Even wound up ditching my old Ubuntu Studio distro. Thank you so much!

lukaszksiezak profile image
Łukasz Księżak

how come, that the tutorial from Microsoft doesn't work and this one is working as a charm...

Thanks Carlos!

zhimz1996 profile image

I managed to download and install everything. thanks a lot

mykhie profile image
Osoro Michael

Thanks man,this is great..

olehkovalchyn profile image

You are a person with a capital letter. You have solved my problem)

darinthompson profile image
Darin Thompson

This was a Godsend. I am new to programming and even newer to Linux and Ubuntu. I was destroying my brain trying to figure this out. Thanks for this.

serdtseva profile image
Elizaveta Serdtseva

OMG, that helped. Thanks! <3 <3 <3

🔍 If you came here from Google, why not take a look at some of our top posts?