DEV Community

loading...
Cover image for Installing DotNet Core in Ubuntu 20.04

Installing DotNet Core in Ubuntu 20.04

Carlos Fabara
Technology, programming and gadget enthusiast.
Updated on ・3 min read

UPDATE: Microsoft added the official docs to Install .NET Core on Ubuntu 20.04 package manager.

UPDATE 2: Added link to scripted installation alternative Scripted Install

The newest Ubuntu LTS release is available now. Sadly, at the time of this writing (April 24th), there is no official installation method for Ubuntu 20.04 listed on the .Net website.

Manual Installation

For this tutorial we are going to manually install DotNet Core 3.1.201 SDK using the binaries provided in the official page.

Download the binaries

Head to .Net Core Downloads and look for the x64 Binaries in the Linux.

Linux Binaries Download page

Alternatively you can use this link to get the specific version used in this tutorial.

Extract and link

After the download finishes, open a Terminal (you can use Super+Alt+T as a shortcut).

Navigate to the folder where it was downloaded and run the following command

mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-3.1.201-linux-x64.tar.gz -C $HOME/dotnet
Enter fullscreen mode Exit fullscreen mode

This command will create a dotnet folder on the user's home directory and extract there the contents of the file.

Note: Please be aware that the file name dotnet-sdk-3.1.201-linux-x64.tar.gz matches the one you downloaded, otherwise you might need to modify the previous command accordingly to your download.

Export variables

Run the following commands to temporarily add the dotnet binaries in your terminal session.

export DOTNET_ROOT=$HOME/dotnet
Enter fullscreen mode Exit fullscreen mode

and

export PATH=$PATH:$HOME/dotnet
Enter fullscreen mode Exit fullscreen mode

Note: This will work only for the current session, at the end of the tutorial you will find instructions to add it permanently.

Test the installation

Run dotnet in the Terminal, and the following should show appear:

Alt Text

Congratulations! You have installed dotnet core.

Permanently add the dotnet command

To add the dotnet commands permanently, you need to add the dotnet folder to the path of your system. To achieve this need to modify the ~/.bashrc file by running.

gedit ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

This will open an editor with the file contents. At the end of the file add the following two lines:

export PATH=$PATH:$HOME/dotnet
export DOTNET_ROOT=$HOME/dotnet
Enter fullscreen mode Exit fullscreen mode

Save the file (Ctrl+S) and close all the open Terminal windows. Next time you open a new one dotnet will be available.

Other installation methods

Package Manager

This is the official way to install dotnet core for Ubuntu based systems. The instructions for the 20.04 version can be found in Package Manager Install

Scripted Install

It has been reported that some PopOS! users might have issues with the official and manual installation methods. In that case it might be solved by using the scripted install method whose instructions can be found in the following link Scripted Install. Thanks to Emma for the contribution.

Discussion (10)

Collapse
maymeow profile image
💜May Meow🌼

I had problem with this instructions (they are same as on microsoft's page) with JetBrain Rider. I returns error it can't connect to Msbuild Even i point it to right place. So i had to use scrpting instalation guide from its page

Collapse
carlos487 profile image
Carlos Fabara Author

Hi Emma do you have the link to that information so I can update the post with it. Thanks

Collapse
maymeow profile image
💜May Meow🌼

Hi here it is... docs.microsoft.com/en-us/dotnet/co... (this is wats working on my Pop_OS 20.10)

Thread Thread
carlos487 profile image
Carlos Fabara Author

I've updated the post with the information provided. Thank you for your contribution Emma

Collapse
antoniofalcao profile image
Antonio Falcão Jr.

Hi May Meow!

I think it can help you:
dev.to/antoniofalcao/using-net-5-w...

Collapse
mainetim profile image
Tim Sweeney

Thanks for this!

Collapse
toastedguy2 profile image
ToastedGuy2

It works +1000 .

Collapse
rfrerebe profile image
Rémy Frèrebeau
Collapse
carlos487 profile image
Carlos Fabara Author

Thanks I will update the post with the new information

Collapse
merrythemes profile image
Merry Themes

Much appreciated Carlos.