So I followed the instructions from microsoft but I can't install dotnet-sdk-5.0 on my ubuntu 20.10 server. I keep getting this:
Does anybody know what can I do?
Time passed quickly, so did packages and their installation methods on Ubuntu. It's end of year 2023, Microsoft has stopped support of .NET 5.0, so you cannot find this version of .NET in Microsoft's repository for Ubuntu 22.04 (like the apt-cache
command in another answer) or use any instructions in official Installation webpages. At the moment, if you wanna install .NET 5.0, follow the commands below:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-runtime-5.0
In the second command, if you are prompted
==> Package distributor has shipped an updated version.
...
*** microsoft-prod.list (Y/I/N/O/D/Z) [default=N] ?
It's safe to just answer Y.
In the last command, you will probably be given:
The following packages have unmet dependencies:
dotnet-runtime-5.0 : Depends: dotnet-runtime-deps-5.0 (>= 5.0.17) but it is not going to be installed
Depends: dotnet-hostfxr-5.0 (>= 5.0.17) but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
Just run sudo apt --fix-broken install
as suggested and this command will automatically install the missing dependent packages for you as well as dotnet-runtime-5.0
.
I tested the above commands on Ubuntu 22.04.
Did you remember to run sudo apt update
before trying to install? If so, let's confirm if the package is available in your Apt cache:
Open a Terminal (if one is not already open)
Check apt-cache
for the dotnet-sdk
packages:
$ sudo apt-cache dump | grep dotnet-sdk
You should get something that looks like this:
Package: dotnet-sdk-2.1
Package: dotnet-sdk-3.1
Package: dotnet-sdk-5.0
Install the package that you'd like:
$ sudo apt install dotnet-sdk-5.0
Which should then result in:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0 dotnet-host dotnet-hostfxr-5.0 dotnet-runtime-5.0
dotnet-runtime-deps-5.0 dotnet-targeting-pack-5.0 netstandard-targeting-pack-2.1
The following NEW packages will be installed
aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0 dotnet-host dotnet-hostfxr-5.0 dotnet-runtime-5.0
dotnet-runtime-deps-5.0 dotnet-sdk-5.0 dotnet-targeting-pack-5.0 netstandard-targeting-pack-2.1
0 to upgrade, 10 to newly install, 0 to remove and 3 not to upgrade.
Need to get 91.9 MB of archives.
After this operation, 382 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Hope this helps you identify why apt couldn't find the package on your system.