❔ ✅ Installing the .NET SDK on Ubuntu 23.04
Does anyone here have experience with installing .NET 7 on Ubuntu?
124 Replies
I followed the docs on MS but they are all over the place and nothing works.
It was this you followed?
https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-2304#install-net
Yes
The install doesnt work - when I run dotnet --info after the install, its says no SDK found
I have been on it for 3 days - I have tried installs with apt and snap - neither work. I have reinstalled vscode a few times but that too cannot find the SDK. Logged to github but no one is picking it up
When you run sudo apt install again what's the output, does it say it installed something or that there was 1 not upgraded or whatever
Yes, it says the SDK is installed - but dotnet --info says its not and dotnet --list-sdks returns a blank line
And the PATH variable does not get added automatically to the ~/.bashrc file
And when I add the PATH manually it still doesnt work
you didn't install the runtime first and then the sdk after from different providers did you?
No, the runtime should install automatically ( which it does ) but the SDK does not install
so when I run dotnet --list-runtimes, the runtime shows
never try installing the runtime or SDK multiple different ways. it will never work. all but one installation is ignored
this is practically guaranteed to be your problem
I learnt that on day one. Then I set about removing all traces of .NET and started again.
so whats the solution?
The issue with multiple feeds was apparently fixed
i mean. you need to nuke everything .NET related on your computer and try again. if the instructions in the article don’t work then you need to figure out why they don’t work rather than try installing it a different way
I have nuked everything - there is not a single file or folder on the system with dotnet in the name
I must have gone through about 40 iterations of cleaning and reinstalling
I have decided the snap package manager does not work - so I have been trying only the apt one
yes, the snap is sort of broken unfortunately
But it looks like thats broken too
did you add the microsoft feed
I am staring down a full reinstall of Ubuntu which I would like to avoid
Yes, went down that route many many times
remove it
Yes, I have removed it
The only thing I havent tried is downloading the binaries and installing manually
do not do that either
Its crazy - why does MS not deal with this
because it works fine
It absolutely does not - check github
This issue is exactly the same as with 6.0 and Ubuntu 22.04 as well as 20.04
do you have
DOTNET_ROOT
set in your environment variablesYes. I tried a number of differnt PATH statements inclusing DOTNET_ROOT
delete that
I have run every imaginable configuration of PATH statement on BOTH snap and apt installs. Nothing works
trying every combination is not the solution
you need to figure out why the recommended solution does not work
Yes, I am testament to that
I have spent 2 days trawling hundreds of posts - Its MS job to figure that out - not mine.
I dont have heavy skills in Linux scripting either.
make sure absolutely every dotnet environment variable, path, file is deleted and just install
dotnet-sdk-7.0
from the Ubuntu repos. if it’s broken we will figure out why it is brokenThe current state of the machine is clean - no mods to the ~/.bashrc and no dotnet files or folders
No point in following the docs - installing the dotnet-sdk-7.0 does not work
sudo apt-get install -y dotnet-sdk-7.0 does not work
I have also done resource ~/.bashrc to make sure the current state of the bashrc file is used
what about it does not work
its all in my third comment
Do you have actual experience with Ubuntu and the .NET 7.0 SDK ?
And running up a container is not the same as having a full Ubuntu install.
i just did this on my install of Ubuntu.
as you can see the SDKs and the runtimes both work perfectly. the fact that it does not work for you means your machine's configuration is screwed up somehow. we can either figure out what's wrong or you can sit here and complain about how microsoft should fix your computer for you
i much prefer the first option
Can you run dotnet --info ? Does it say a SDK was found?
I am not running a macbook
That command does not work on my machine although it says it does
And what version of Ubuntu are you running? - this command worked perfectly for me on 22.04
i'm on 22.04. are you on a different version?
Yes, 23.04
Yes, it works for you. It worked for me too on 22.04
can you check if the PATH was updated/added in your bash?
Looks fine -
so, after you install the package, when you do
dotnet --list-sdks
, it says you have noneit just returns a blank line
dotnet --info says there is no SDKs found
but it does find the runtime
what does
ls /usr/lib/dotnet/sdk
give youls: cannot access '/usr/lib/dotnet/sdk': No such file or directory
The machine is clean
echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/greg/.dotnet/tools
whereis dotnet
dotnet: /etc/dotnet
if you still have the
dotnet
program then the machine isn't cleanecho $DOTNET_ROOT returns a blank line
hmmm - i didnt clean .dotnet folders
what does
ls /etc/dotnet
give youinstall_location install_location_x64
you definitely need to nuke that folder too
ok
rm: cannot remove 'install_location': No such file or directory
just
sudo rm -rf /etc/dotnet
ls /etc/dotnet
ls: cannot access '/etc/dotnet': No such file or directory
i guess you already deleted it then
yes
now
whereis dotnet
is empty right? if you do dotnet
then it'll tell you dotnet
is not found, right?whereis dotnet
dotnet:
dotnet
Command 'dotnet' not found, but can be installed with:
sudo snap install dotnet-sdk # version 7.0.401, or
sudo apt install dotnet-host # version 6.0.122-0ubuntu1~23.04.1
sudo apt install dotnet-host-7.0 # version 7.0.111-0ubuntu1~23.04.1
See 'snap info dotnet-sdk' for additional versions.
dotnet --info
Host:
Version: 7.0.11
Architecture: x64
Commit: ecb34f85ec
.NET SDKs installed:
No SDKs were found.
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
dotnet command - .NET CLI
Learn about the dotnet command (the generic driver for the .NET CLI) and its usage.
Microsoft
.NET Downloads (Linux, macOS, and Windows)
Official .NET downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
seems like it's working
No SDKs found
oh
i see
try
echo $DOTNET_ROOT
blank like
same with dotnet --list-sdks
can you reopen your terminal and try again
dotnet --list-runtimes
Microsoft.AspNetCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]
reopened terminal and cleaned and installed - same
So , the runtime is installed but not the SDKs
okay. what is
ls /usr/lib/dotnet/sdk
ls: cannot access '/usr/lib/dotnet/sdk': No such file or directory
ls /usr/lib/dotnet
ls /usr/lib/dotnet
dotnet host LICENSE.txt packs shared ThirdPartyNotices.txt
apt list --installed dotnet*
apt list --installed dotnet*
Listing... Done
so it's empty
yep
can you send the output that you get when you run
sudo apt install dotnet7
ok
greg@greg-ThinkPad-E520:~$ sudo apt install dotnet7
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
aspnetcore-runtime-7.0 aspnetcore-targeting-pack-7.0 dotnet-sdk-7.0
The following NEW packages will be installed
aspnetcore-runtime-7.0 aspnetcore-targeting-pack-7.0 dotnet-sdk-7.0 dotnet7
0 to upgrade, 4 to newly install, 0 to remove and 18 not to upgrade.
Need to get 28.4 kB/117 MB of archives.
After this operation, 448 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:1 http://fr.archive.ubuntu.com/ubuntu lunar-updates/universe amd64 dotnet7 amd64 7.0.111-0ubuntu1~23.04.1 [28.4 kB]
Fetched 28.4 kB in 0s (255 kB/s)
Selecting previously unselected package aspnetcore-targeting-pack-7.0. (Reading database ... 280264 files and directories currently installed.) Preparing to unpack .../aspnetcore-targeting-pack-7.0_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking aspnetcore-targeting-pack-7.0 (7.0.111-0ubuntu1~23.04.1) ... Selecting previously unselected package aspnetcore-runtime-7.0. Preparing to unpack .../aspnetcore-runtime-7.0_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking aspnetcore-runtime-7.0 (7.0.111-0ubuntu1~23.04.1) ... Selecting previously unselected package dotnet-sdk-7.0. Preparing to unpack .../dotnet-sdk-7.0_7.0.401-1_amd64.deb ... Unpacking dotnet-sdk-7.0 (7.0.401-1) ... Selecting previously unselected package dotnet7. Preparing to unpack .../dotnet7_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking dotnet7 (7.0.111-0ubuntu1~23.04.1) ... Setting up aspnetcore-targeting-pack-7.0 (7.0.111-0ubuntu1~23.04.1) ... Setting up aspnetcore-runtime-7.0 (7.0.111-0ubuntu1~23.04.1) ... Setting up dotnet-sdk-7.0 (7.0.401-1) ... Setting up dotnet7 (7.0.111-0ubuntu1~23.04.1) ... greg@greg-ThinkPad-E520:~$
Selecting previously unselected package aspnetcore-targeting-pack-7.0. (Reading database ... 280264 files and directories currently installed.) Preparing to unpack .../aspnetcore-targeting-pack-7.0_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking aspnetcore-targeting-pack-7.0 (7.0.111-0ubuntu1~23.04.1) ... Selecting previously unselected package aspnetcore-runtime-7.0. Preparing to unpack .../aspnetcore-runtime-7.0_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking aspnetcore-runtime-7.0 (7.0.111-0ubuntu1~23.04.1) ... Selecting previously unselected package dotnet-sdk-7.0. Preparing to unpack .../dotnet-sdk-7.0_7.0.401-1_amd64.deb ... Unpacking dotnet-sdk-7.0 (7.0.401-1) ... Selecting previously unselected package dotnet7. Preparing to unpack .../dotnet7_7.0.111-0ubuntu1~23.04.1_amd64.deb ... Unpacking dotnet7 (7.0.111-0ubuntu1~23.04.1) ... Setting up aspnetcore-targeting-pack-7.0 (7.0.111-0ubuntu1~23.04.1) ... Setting up aspnetcore-runtime-7.0 (7.0.111-0ubuntu1~23.04.1) ... Setting up dotnet-sdk-7.0 (7.0.401-1) ... Setting up dotnet7 (7.0.111-0ubuntu1~23.04.1) ... greg@greg-ThinkPad-E520:~$
fr.archive.ubuntu.com / ubuntu.lafibre.info
Archive of Ubuntu
and now if you
ls /usr/lib/dotnet
ls /usr/lib/dotnet
dotnet host LICENSE.txt packs shared ThirdPartyNotices.txt
apt list --installed dotnet*
Listing... Done
are we done?
how about
dpkg-query --list dotnet*
this is looking like an ubuntu issue and not a dotnet issueok
dpkg-query --list dotnet*
dpkg-query: no packages found matching dotnet-install.sh
try
dpkg-query --list dotnet\*
it is not supposed to expand to dotnet-install.shdpkg-query --list dotnet*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=========================-========================-============-=======================================================
un dotnet-apphost-pack-6.0 <none> <none> (no description available)
ii dotnet-apphost-pack-7.0 7.0.111-0ubuntu1~23.04.1 amd64 Internal - targeting pack for Microsoft.NETCore.App 7.0
un dotnet-host <none> <none> (no description available)
ii dotnet-host-7.0 7.0.111-0ubuntu1~23.04.1 amd64 dotNET host command line
un dotnet-hostfxr-6.0 <none> <none> (no description available)
ii dotnet-hostfxr-7.0 7.0.111-0ubuntu1~23.04.1 amd64 dotNET host resolver
un dotnet-runtime-6.0 <none> <none> (no description available)
ii dotnet-runtime-7.0 7.0.111-0ubuntu1~23.04.1 amd64 dotNET runtime
ii dotnet-sdk-7.0 7.0.401-1 amd64 Microsoft .NET SDK 7.0.401
un dotnet-targeting-pack-6.0 <none> <none> (no description available)
ii dotnet-targeting-pack-7.0 7.0.111-0ubuntu1~23.04.1 amd64 Internal - targeting pack for Microsoft.NETCore.App 7.0
un dotnet6 <none> <none> (no description available)
ii dotnet7 7.0.111-0ubuntu1~23.04.1 amd64 dotNET CLI tools and runtime
dpkg --listfiles dotnet-sdk-7.0
whooaa - you want all that?
Its big
do they mostly start with /usr/lib/dotnet/sdk/7.0.111/
here is a sample
sorry - cant send - server is blocking it
/usr/share/dotnet/sdk/7.0.401/Containers/containerize/Microsoft.Build.Framework.dll
hmmmmmmm
/usr/share/dotnet/sdk/7.0.401/DotnetTools/dotnet-format/ru/Microsoft.CodeAnalysis.Features.resources.dll
ls /usr/share/dotnet
Can you test this inside a 23.04 container?
ls /usr/share/dotnet
sdk sdk-manifests templates
if it really installed to
/usr/share/dotnet
instead of /usr/lib/dotnet
this would explain the issue
indeed, that seems to be the issue
so, it's isntalling the SDK to a different place from the runtime
now the question is, whyok
so why does it work for you?
Is this only on 23.04?
or is it the package causing the issue
ah. 7.0.401
i see the issue
the SDK is coming from the micrisoft repos
but the runtime is coming from the ubuntu repos
aha
the ubuntu repos onl have 7.0.1xx so that is for sure the issue
they were supposed to fix this - there was a github issue that was closed on this
try just to remove everything dotnet related. make sure
/usr/share/dotnet
is gone once you do that
can you run ls /etc/apt/sources.list.d/microsoft-prod.list
ls /etc/apt/sources.list.d/microsoft-prod.list
ls: cannot access '/etc/apt/sources.list.d/microsoft-prod.list': No such file or directory
dpkg -l packages-microsoft-prod.deb
dpkg -l packages-microsoft-prod.deb
dpkg-query: no packages found matching packages-microsoft-prod.deb
whereis microsoft
?whereis microsoft
microsoft:
ls /etc/apt/preferences
ls /etc/apt/preferences
ls: cannot access '/etc/apt/preferences': No such file or directory
apt-cache policy 'dotnet.*'
cat /etc/apt/sources.list
cat /etc/apt/sources.list
deb cdrom:[Ubuntu 22.10 Kinetic Kudu - Release amd64 (20221020)]/ kinetic main restricted
See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
newer versions of the distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ lunar main restricted
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic main restricted
Major bug fix updates produced after the final release of the
distribution.
deb http://fr.archive.ubuntu.com/ubuntu/ lunar-updates main restricted
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic-updates main restricted
N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
team. Also, please note that software in universe WILL NOT receive any
review or updates from the Ubuntu security team.
deb http://fr.archive.ubuntu.com/ubuntu/ lunar universe
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic universe
deb http://fr.archive.ubuntu.com/ubuntu/ lunar-updates universe
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic-updates universe
N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
team, and may not be under a free licence. Please satisfy yourself as to
your rights to use the software. Also, please note that software in
multiverse WILL NOT receive any review or updates from the Ubuntu
security team.
deb http://fr.archive.ubuntu.com/ubuntu/ lunar multiverse
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic multiverse
deb http://fr.archive.ubuntu.com/ubuntu/ lunar-updates multiverse
deb-src http://fr.archive.ubuntu.com/ubuntu/ kinetic-updates multiverse
N.B. software from this repository may not have been tested as
extensively as that contained in the main release, although it includes
fr.archive.ubuntu.com / ubuntu.lafibre.info
Archive of Ubuntu
hm, well, it seems like the microsoft repo really is gone... can you do
sudo apt update
and paste the outputsudo apt update
[sudo] password for greg:
Hit:1 http://security.ubuntu.com/ubuntu lunar-security InRelease
Hit:2 http://fr.archive.ubuntu.com/ubuntu lunar InRelease
Hit:3 http://fr.archive.ubuntu.com/ubuntu lunar-updates InRelease
Hit:4 http://fr.archive.ubuntu.com/ubuntu lunar-backports InRelease
Hit:5 https://ppa.launchpadcontent.net/linuxgndu/sqlitebrowser/ubuntu lunar InRelease
Hit:6 https://linux.teamviewer.com/deb stable InRelease
Hit:7 https://packages.microsoft.com/repos/azure-cli jammy InRelease
Hit:8 https://packages.microsoft.com/repos/microsoft-ubuntu-lunar-prod lunar InRelease
Hit:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu lunar InRelease Get:10 https://packages.microsoft.com/repos/edge stable InRelease [3,569 B] Get:11 https://packages.microsoft.com/repos/edge stable/main amd64 Packages [8,555 B] Fetched 12.1 kB in 2s (6,685 B/s)
Reading package lists... Done Building dependency tree... Done Reading state information... Done 18 packages can be upgraded. Run 'apt list --upgradable' to see them.
Hit:3 http://fr.archive.ubuntu.com/ubuntu lunar-updates InRelease
Hit:4 http://fr.archive.ubuntu.com/ubuntu lunar-backports InRelease
Hit:5 https://ppa.launchpadcontent.net/linuxgndu/sqlitebrowser/ubuntu lunar InRelease
Hit:6 https://linux.teamviewer.com/deb stable InRelease
Hit:7 https://packages.microsoft.com/repos/azure-cli jammy InRelease
Hit:8 https://packages.microsoft.com/repos/microsoft-ubuntu-lunar-prod lunar InRelease
Hit:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu lunar InRelease Get:10 https://packages.microsoft.com/repos/edge stable InRelease [3,569 B] Get:11 https://packages.microsoft.com/repos/edge stable/main amd64 Packages [8,555 B] Fetched 12.1 kB in 2s (6,685 B/s)
Reading package lists... Done Building dependency tree... Done Reading state information... Done 18 packages can be upgraded. Run 'apt list --upgradable' to see them.
fr.archive.ubuntu.com / ubuntu.lafibre.info
Archive of Ubuntu
well, i guess it's still there somewhere
you are now way above my paygrade
ls /etc/apt/sources.list.d
? maybe it's called something elses /etc/apt/sources.list.d
azure-cli.list linuxgndu-ubuntu-sqlitebrowser-lunar.list microsoft-edge.list.distUpgrade ubuntu-toolchain-r-ubuntu-test-lunar.list
dotnetdev.list microsoft-edge.list teamviewer.list
hm, well, can you
cat /etc/apt/sources.list.d/dotnetdev.list
that seems like it might be itcat /etc/apt/sources.list.d/dotnetdev.list
deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-lunar-prod lunar main
delete that file
then do
sudo apt update
again
make sure https://packages.microsoft.com/repos/microsoft-ubuntu-lunar-prod is not one of the sources it lists when you do thatsudo apt update
Hit:1 http://fr.archive.ubuntu.com/ubuntu lunar InRelease
Hit:2 http://fr.archive.ubuntu.com/ubuntu lunar-updates InRelease
Hit:3 https://linux.teamviewer.com/deb stable InRelease
Hit:4 http://fr.archive.ubuntu.com/ubuntu lunar-backports InRelease
Hit:5 https://ppa.launchpadcontent.net/linuxgndu/sqlitebrowser/ubuntu lunar InRelease
Hit:6 http://security.ubuntu.com/ubuntu lunar-security InRelease
Hit:7 https://packages.microsoft.com/repos/azure-cli jammy InRelease
Hit:8 https://packages.microsoft.com/repos/edge stable InRelease
Hit:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu lunar InRelease Reading package lists... Done
Building dependency tree... Done Reading state information... Done 18 packages can be upgraded. Run 'apt list --upgradable' to see them.
Hit:3 https://linux.teamviewer.com/deb stable InRelease
Hit:4 http://fr.archive.ubuntu.com/ubuntu lunar-backports InRelease
Hit:5 https://ppa.launchpadcontent.net/linuxgndu/sqlitebrowser/ubuntu lunar InRelease
Hit:6 http://security.ubuntu.com/ubuntu lunar-security InRelease
Hit:7 https://packages.microsoft.com/repos/azure-cli jammy InRelease
Hit:8 https://packages.microsoft.com/repos/edge stable InRelease
Hit:9 https://ppa.launchpadcontent.net/ubuntu-toolchain-r/test/ubuntu lunar InRelease Reading package lists... Done
Building dependency tree... Done Reading state information... Done 18 packages can be upgraded. Run 'apt list --upgradable' to see them.
fr.archive.ubuntu.com / ubuntu.lafibre.info
Archive of Ubuntu
okay. now you can try
sudo apt install dotnet7
wooohooo
you did it!
no idea how you did it but you did
thanks -
summary?
i mean, it's the same issue as most other people are having--the .NET SDK was coming from the microsoft repos, but the runtime was coming from the Ubuntu repos, and the two do not mix because they install to different folders
https://learn.microsoft.com/en-Us/dotnet/core/install/linux-package-mixup?pivots=os-linux-other#whats-going-on
for you it seemed to have installed some packages from Ubuntu and some from Microsoft. i do not know why exactly it chose to do this, but it shouldn't be able to in the first place
OK - I respect your tenacity and help
anyway, just deleting the microsoft repo and reinstaling everything makes it work. in the future, if you need the microsoft repos for some other software--maybe you want PowerShell or SQL Server--you will need to make sure it does not start pulling dotnet from there
will do - Thanks again
quick question - do I need to manually update the PATH?
no
dotnet
is put into /usr/bin
which is installed into the PATH alreadyok
👍
If you were in France, you would be getting a special bottle of wine!
i'm glad i could help!
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.