简体   繁体   中英

How to install dotnet SDK on Ubuntu 16.04 LTS

I have been following the instructions provided here: https://docs.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?

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!

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

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.

One reason why apt is unable to locate the packages is that they are not available for your processor architecture. The dotnet core Linux libraries do not support the 32-bit PC (i386, i686), only the 64-bit PC (amd64) are supported. If you happen to have a Ubuntu install of a different architecture, apt-get will report the aforementioned error:

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

Check your current architecture with the command:

arch

If this returns anything else than amd64, you're probably out of luck. Unless you installed a 32-bit PC Ubuntu image on a 64-bit PC. If that's the case, reinstall Ubuntu, using a 64-bit PC (AMD64) install image.

The update is missing:

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

When doing sudo apt-get update you may get this error:

W: GPG error: https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
E: The repository 'https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

Note that it's not that obvious (it's all the same font color and can be easily overlooked if you don't read everything that gets printed to the console output).

It can be fixed with this command:

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 6494C6D6997C215E

I'm not really sure what it actually does, looks like adding a 3rd party certificate authority or something like that. Any way, after redoing sudo apt-get update and sudo apt-get install dotnet-sdk-2.1.4 the package can finally be installed without the "couldn't find" errors.

This answer is bit late but I believe act of adding value is never late .

I found these writing links below to be very helpfull and detailed it is detailed enough about installing the ubuntu on linux and discussing .NET Core releases and versions of Ubuntu they are supported on.

INSTALL DOTNET CORE LINUX : HOW TO INSTALL .NET CORE ON UBUNTU

It also has link on how to install latest ubuntu 20.04 as well.

How to Install .NET core 3.1 on Ubuntu 20.04 LTS (Focal Fossa) .NET Core 发行版和支持它们的 Ubuntu 版本。

On WSL 16.04 I couldn't resolve the Microsoft or debian server locations. Here were the steps I took:

cd /etc/

sudo chmod 777 resolv.conf

cat resolv.conf (if no 8.8.8.8 for Google dns then follow the next line)

echo "nameserver 8.8.8.8" >> resolv.conf

sudo wget http://ftp.us.debian.org/debian/pool/main/i/icu/libicu57_57.1-6+deb9u4_amd64.deb

sudo dpkg -i libicu57_57.1-6+deb9u4_amd64.deb

sudo apt install dotnet-sdk-3.1 (change the version number to the one you want)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM