Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install dotnet SDK on Ubuntu 16.04 LTS

I have been following the instructions provided here: https://learn.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x

However, I keep getting the error when I try to run"

sudo apt-get install dotnet-sdk-2.1.4

Specifically it says:

E: Unable to locate package dotnet-sdk-2.1.4
E: Couldn't find any package by glob 'dotnet-sdk-2.1.4'
E: Couldn't find any package by regex 'dotnet-sdk-2.1.4'

However, doing a sudo apt search dotnet results in the package showing up.

Am I doing something wrong?

like image 673
Aerophilic Avatar asked Feb 10 '18 01:02

Aerophilic


People also ask

Can we install .NET on Ubuntu?

. NET is supported on Ubuntu. This article describes how to install .

How do I know if .NET SDK is installed?

You can see both the SDK versions and runtime versions with the command dotnet --info .

Where is .NET Core SDK installed?

NET are installed to the normal C:\Program Files\dotnet\ folder. However, when you install the x64 version of . NET 6 SDK, it's installed to the C:\Program Files\dotnet\x64\ folder.


3 Answers

Try running this command on your terminal:

wget -q packages-microsoft-prod.deb https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

Then update your system:

sudo apt-get update

Finally, run the command to install .NET

sudo apt-get install dotnet-sdk-2.1.4

Hope that helps!

like image 75
Ali Nobari Avatar answered Nov 02 '22 23:11

Ali Nobari


Ensure you're running the prerequisite commands also:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

And finally:

sudo apt-get update
sudo apt-get install dotnet-sdk-2.1.4
like image 41
Sam Ashton Avatar answered Nov 02 '22 23:11

Sam Ashton


Looks as if the deb package to set up the apt repo has some issues. As a quick fix do after installing the ms repo setup package:

sudo cp \
  /etc/apt/sources.list.d/microsoft-prod.list.save \
  /etc/apt/sources.list.d/microsoft-prod.list

 sudo apt-get update
 sudo apt-get install dotnet-sdk-2.1

Fix worked on ubuntu 18.04 but seems to be the same issue here.

like image 1
Georg Avatar answered Nov 02 '22 23:11

Georg