dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
21.02k stars 4.91k forks source link

Installing .NET 6 on Ubuntu 22.04 (Jammy) #7699

Open richlander opened 2 years ago

richlander commented 2 years ago

Installing .NET 6 on Ubuntu 22.04 (Jammy)

We announced support for .NET 6 on Ubuntu 22.04 with our May 2022 Updates. At that time, the supported installation methods were manual installation via a tarball or a .deb package via packages.microsoft.com (PMC). .NET 6 is now available natively via Jammy feeds, which can cause conflicts with PMC feeds. You need to apply the following guidance to install .NET 6 reliably and correctly on Ubuntu 22.04+.

More information will be shared shortly on .NET 6 being available natively in the jammy-updates feed. In general, we recommend that you use the native packages from this feed since it is much easier and simpler.

You can use one of the following scenarios:

Related:

Clean machine scenario 1: Use .NET 6 Package via Jammy feed

The easiest approach is to use the .NET 6 package available in Jammy feeds. In this scenario, just install dotnet6 and don't register the PMC feed.

You can do that via the following commands:

sudo apt update && sudo apt -y install dotnet6

You can see this demonstrated with Docker:

$ docker run --rm -it ubuntu:jammy
root@4c9d58f507a3:/# apt update && apt install -y dotnet6
root@444999ffd672:/# dotnet --version
6.0.108

Note: This build of .NET 6 is for the 6.0.1xx band. 6.0.4xx builds are available via PMC. That difference matters most to Windows users. Both builds are supported.

Clean machine scenario 2: Use .NET 6 Package via PMC

You can install .NET 6 on Ubuntu 22.04 from packages.microsoft.com using the following steps:

wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb

Configure apt preferences, to prioritize PMC repository, by creating the following file: /etc/apt/preferences

To create the file:

sudo touch /etc/apt/preferences

with contents:

Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001

Update your APT information:

sudo apt update

Install .NET SDK 6.0:

sudo apt install dotnet-sdk-6.0

Mixed state scenario 1: Use native Jammy packages after installing a previous .NET release from PMC

You may want to switch to using the .NET 6 package available in Jammy after installing .NET 6 from PMC.

Do the following:

  1. Remove all .NET packages

sudo apt remove --purge dotnet* sudo apt remove --purge aspnetcore*

  1. Delete PMC repository from APT, using any of the typical methods, for instance by deleting the repo .list file

sudo rm /etc/apt/sources.list.d/microsoft-prod.list

  1. Update APT

sudo apt update

  1. Install .NET SDK 6.0

sudo apt install dotnet-sdk-6.0

Mixed state scenario 2: Use PMC packages after installing native Jammy packages

You may want to switch to using packages.microsoft.com packages after installing native packages, potentially because you want to use 6.0.4xx builds.

Do the following:

  1. Remove all .NET packages

sudo apt remove --purge dotnet* sudo apt remove --purge aspnetcore*

  1. Create apt preferences file as specified in the section above
  2. Install .NET SDK 6.0

sudo apt install dotnet-sdk-6.0

How to identify which packages you'd installed

We'll install .NET 6 with both feeds, from a clean state, and then point the various ways you can identify which feed you installed the package from.

First, let's install the native Jammy packages using the "Clean machine scenario 1" guidance.

rich@kamloops:~$ docker run --rm -it ubuntu:jammy
root@db7fd8ec177e:/# apt update && apt install -y dotnet6
Get:18 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet6 amd64 6.0.108-0ubuntu1~22.04.1 [20.5 kB]
root@db7fd8ec177e:/# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.108
 Commit:    4e3a463d2b

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.108/

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  6.0.108 [/usr/lib/dotnet/dotnet6-6.0.108/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

Notice that we've installed .NET SDK 6.0.108, installed to /usr/lib/dotnet/, and that the dotnet6 package is being installed from http://archive.ubuntu.com/ubuntu jammy-updates/universe. That's expected for the native packages.

Let's try the same thing with PMC, but with the "Clean machine scenario 2" guidance.

rich@kamloops:~$ docker run --rm -it ubuntu:jammy
root@626dcadc888b:/# apt update && apt install -y wget 
root@626dcadc888b:/# wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
root@626dcadc888b:/# dpkg -i packages-microsoft-prod.deb
root@626dcadc888b:/# rm packages-microsoft-prod.deb
root@626dcadc888b:/# touch /etc/apt/preferences
root@626dcadc888b:/# echo "Package: *" >> /etc/apt/preferences
root@626dcadc888b:/# echo "Pin: origin \"packages.microsoft.com\"" >> /etc/apt/preferences
root@626dcadc888b:/# echo Pin-Priority: 1001 >> /etc/apt/preferences
root@626dcadc888b:/# cat /etc/apt/preferences
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001
root@626dcadc888b:/# apt update && apt -y install dotnet-sdk-6.0
Get:11 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 dotnet-sdk-6.0 amd64 6.0.400-1 [86.4 MB]
root@626dcadc888b:/# dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.400
 Commit:    7771abd614

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  22.04
 OS Platform: Linux
 RID:         ubuntu.22.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.400/

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  6.0.400 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

Notice that we've installed .NET SDK 6.0.400, installed to /usr/share/dotnet/, and that the dotnet6 package is being installed from https://packages.microsoft.com/ubuntu/22.04/prod jammy/main. That's expected for PMC packages.

We can also tell if the Microsoft PMC feed is registered:

root@626dcadc888b:/# ls /etc/apt/sources.list.d/
microsoft-prod.list
root@626dcadc888b:/# cat /etc/apt/sources.list.d/microsoft-prod.list 
deb [arch=amd64,arm64,armhf] https://packages.microsoft.com/ubuntu/22.04/prod jammy main

If you are using native packages, that file won't and shouldn't be present.

omajid commented 2 years ago

Should we add these to https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-mixup ?

mirespace commented 2 years ago

Should we add these to https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-mixup ?

A set of modifications for the page was here too: https://github.com/dotnet/docs/issues/30457#issuecomment-1209280875

smitssjors commented 2 years ago

https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2204 should be updated too.

richlander commented 2 years ago

Can you elaborate @bastare?

khteh commented 2 years ago

Tried the steps but to no avail. Ubuntu 22.04

$ dn --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info
owenholloway commented 2 years ago

This is specific to package version 6.0.8+. Downgrading to 6.0.7 resulted in the SDK showing.

richlander commented 2 years ago

Did folks who are having this problem follow the instructions? If so, did you go with scenario 1 or 2?

jub0t commented 2 years ago

Thanks so much, I've been trying to fix the error for hours, Scenario 1 did it for me.

Edit: I was using Ubuntu Jammy.

richlander commented 2 years ago

I updated the scenarios to make them clearer. We now have two "Clean machine" scenarios and two "Mixed-state" scenarios. I've kept the numbering the same.

BTW: We are very sorry that this situation occurred. We should have predicted that it would but sadly did not. That's on us. We've learned that mix-and-matching package feeds with the same package names that install to different locations is a recipe for what we're seeing here. Again, we're sorry about that and won't repeat it.

khteh commented 2 years ago

Why is there this sudden change of installation steps? Is this going to be the one used moving forward?

ar0311 commented 2 years ago

What do we do if we want powershell installed from PMC but to install SDK from jammy repo?

Also removing and re-installing dotnet and aspnetcore did not fix the issue for me either.

alexisatkinson commented 2 years ago

Did folks who are having this problem follow the instructions? If so, did you go with scenario 1 or 2?

After some trial and error, found this github issue and went with "Clean machine scenario 2: Use .NET 6 Package via PMC" as this allows using the latest dotnet 6 sdk version. These instructions worked well.

mickdelaney commented 2 years ago

How can I get dotnet 5 SDK installed on 22.04 ? Its not supported using packages. does this mean i cant use the native packages if i want to use SDK 5 & 6 ?

carstencodes commented 2 years ago

In our company we're using a mirror with the same starting url for both feeds - PMC and Ubuntu sources.

Hence pinning won't work by setting

Pin: release mirror.company.com

Instead the following configuration works for me:

Package: *
Pin: release o=microsoft-ubuntu-jammy-prod jammy, n=jammy, a=jammy, c=main
Pin-Priority: 1001

Just in case anybody has a similar issue...

richlander commented 2 years ago

@mickdelaney Only .NET 6+ is supported on Ubuntu 22.04. That's unrelated to this discussion. See: https://github.com/dotnet/core/issues/7038#issuecomment-1110377345

.NET 6 is our first release to support OpenSSL v3. Ubuntu 22.04 only includes OpenSSL v3. As a result .NET 5 cannot function. You can install OpenSSL v1.x yourself if needed. We don't support that. Same thing with .NET Core 3.1. Also, .NET 5 is EOL.

richlander commented 2 years ago

Why is there this sudden change of installation steps? Is this going to be the one used moving forward?

We've been working with Canonical to make .NET available in the official feeds. That landed last week. We're making an official announcement tomorrow to better describe the change. This is a case where technical and marketing dates didn't match, sadly. We tried our best to resolve this situation by posting this issue with these instructions within a couple hours of realizing what had happened. We've updated the instructions a few times based on feedback and better understanding the mechanics to help users adapt to the new packages.

NikolaMilosavljevic commented 2 years ago

Tried the steps but to no avail. Ubuntu 22.04

$ dn --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

@khteh which exact scenario steps were attempted? We have steps for 2 clean and 2 mixed scenarios.

NikolaMilosavljevic commented 2 years ago

What do we do if we want powershell installed from PMC but to install SDK from jammy repo?

Also removing and re-installing dotnet and aspnetcore did not fix the issue for me either.

@ar0311 which exact scenario steps were attempted? We have steps for 2 clean and 2 mixed scenarios.

NikolaMilosavljevic commented 2 years ago

What do we do if we want powershell installed from PMC but to install SDK from jammy repo?

For this scenario, the following would work:

  1. Create apt preferences file (/etc/apt/preferences) with the following contents:
Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 400
  1. Follow steps for installing Powershell on Ubuntu from https://docs.microsoft.com/en-us/powershell/scripting/install/install-ubuntu?view=powershell-7.2

  2. Install .NET SDK - it would be obtained from Jammy repos.

SalihKARAHAN commented 2 years ago

Tried the steps but to no avail. Ubuntu 22.04

$ dn --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

I had the same issue and I tried the Mixed state scenario 2 and it works

lol768 commented 2 years ago

The official Jammy .NET package is not fit for purpose and conflicts with software like Discord.

This used to work absolutely fine with the PMC packages. Whilst I'm supportive of making .NET more widely available like this, and easier to install, this seems like a step backwards.

I'm now having to work-around this by messing with /etc/apt/preferences - not a great developer experience.

richlander commented 2 years ago

There is a Canonical bug tracking this: https://bugs.launchpad.net/ubuntu/+source/dotnet6/+bug/1984450

warriordog commented 2 years ago

In case this helps anyone, I had to add a step to mixed-state scenario 2. I was not able to install the PMC packages until I purged and reinstalled the PMC repository like this:

sudo dpkg --purge packages-microsoft-prod
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update

You can verify that the repository is working by running apt-cache policy dotnet-sdk-6.0. You should see a whole bunch of entries from packages.microsoft.com. If you only see entries from archive.ubuntu.com, then the repository is broken and dotnet will be installed from canonical repositories even if you pinned the packages in apt preferences file.

sakno commented 2 years ago

.NET SDK version from Jammy package repo is outdated. The current version is 6.0.108 instead of 6.0.400

mirespace commented 2 years ago

Hi @sakno,

unfortunately, 6.0.4xx cannot be built from source for Ubuntu (nor for Linux distros in general) because it's not supported:

sakno commented 2 years ago

Hi @sakno,

unfortunately, 6.0.4xx cannot be built from source for Ubuntu (nor for Linux distros in general) because it's not supported:

* https://github.com/dotnet/source-build#support

* https://bugs.launchpad.net/ubuntu/+source/dotnet6/+bug/1984451/comments/4

OMG, switching back to packages.microsoft.com

omajid commented 2 years ago

OMG, switching back to packages.microsoft.com

Could you share more information about what missing features in 6.0.1xx motivate the switch?

sakno commented 2 years ago

@omajid , sure. The latest version of SDK has some updates on Roslyn compiler. I found that my code can be compiled on the earlier versions but not on the latest. For instance,

using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

public struct C {
    private int value;

    private Span<byte> Span => MemoryMarshal.AsBytes(MemoryMarshal.CreateSpan(ref value, 1));
}

Thus, the latest Roslyn update introduces incompatible changes at the source level.

omajid commented 2 years ago

Oh. I thought you meant the opposite...

Ubuntu has the older 6.0.1xx SDK (with older Roslyn), compared to packages.microsoft.com. If I am reading your concerns correctly, you want to avoid packages.microsoft.com?

sakno commented 2 years ago

@omajid , no, I can't use it because as a maintainer of OSS project I need to be sure that everyone who cloned the repo is able to build the project locally (and remotely on Azure DevOps). So, everything that can be compiled on 6.0.4x can be compiled on 6.0.1x but not vice versa.

aaronfranke commented 2 years ago

When will support for Arm64 .NET 6 come to the Ubuntu package? It's not available when I try to install it. This website says it's only for amd64 (aka x86_64), but Microsoft's download page also provides binaries for Arm32 and Arm64 Linux. Please add the Arm64 architecture version to the Ubuntu package.

SaeidAshian commented 2 years ago

Is Microsoft released package for .net 7 sdk on 22.04?

mirespace commented 2 years ago

When will support for Arm64 .NET 6 come to the Ubuntu package? It's not available when I try to install it. This website says it's only for amd64 (aka x86_64), but Microsoft's download page also provides binaries for Arm32 and Arm64 Linux. Please add the Arm64 architecture version to the Ubuntu package.

We're working on it.

lonix1 commented 2 years ago

Upgraded to ubuntu 22 and hit this problem. I want the latest version, from the MS repo, not an older version from canonical. I've tried every approach but none worked (for me).

Does someone have a complete working script that installs from the MS repo?

a-l-e-x-d-s-9 commented 2 years ago

@lonix1 I have used dotnet-install.sh to install dotnet sdk 6.0.400 and runtime in home/.dotnet folder, it worked alongside existing version (6.0.108) installed in the system with package manager. I'm not sure, if it is possible to remove the version from package manager, and use dotnet-install.sh to install latest version into systems' folders for all users.

mickdelaney commented 2 years ago

Upgraded to ubuntu 22 and hit this problem. I want the latest version, from the MS repo, not an older version from canonical. I've tried every approach but none worked (for me).

Does someone have a complete working script that installs from the MS repo?

I removed all the packages and went for manual install using the dotnet-install.she also, works for me

lonix1 commented 2 years ago

Thanks guys. What eventually worked for me was this approach. It uses apt pinning.

flyfishMT commented 2 years ago

Hello, I'm confused over whether to install the dotnet-sdk-6.0 or dotnet6 package. I followed "Mixed state scenario 1: Use native Jammy packages after installing a previous .NET release from PMC" and installed dotnet-sdk-6.0 and all is well (I have an sdk and runtime listed in dotnet --info), but throughout this thread it often states to install package dotnet6, which do I want?

FilBot3 commented 2 years ago

I just installed (on Ubuntu 22.04), following this:

sudo apt install dotnet6

then when I

dotnet --list-sdks

Nothing shows up.

Then when I attempt to build a package, I get

> dotnet build
The command could not be loaded, possibly because:
  * You intended to execute a .NET application
        The application build does not exist.
  *  You intended to execute a .NET SDK command
        No .NET SDKs were found.

However, the install log says other wise...

Ubuntu apt install log ```bash ➜ ~ sudo apt remove dotnet\* [sudo] password for filbot: Reading package lists... Done Building dependency tree... Done Reading state information... Done Note, selecting 'dotnet-hostfxr-3.1' for glob 'dotnet*' Note, selecting 'dotnet-hostfxr-6.0' for glob 'dotnet*' Note, selecting 'dotnet-sdk-6.0' for glob 'dotnet*' Note, selecting 'dotnet6' for glob 'dotnet*' Note, selecting 'dotnet-targeting-pack-6.0' for glob 'dotnet*' Note, selecting 'dotnet-nightly' for glob 'dotnet*' Note, selecting 'dotnet-templates-6.0' for glob 'dotnet*' Note, selecting 'dotnet-host' for glob 'dotnet*' Note, selecting 'dotnet-runtime-deps-3.1' for glob 'dotnet*' Note, selecting 'dotnet-runtime-deps-6.0' for glob 'dotnet*' Note, selecting 'dotnet' for glob 'dotnet*' Note, selecting 'dotnet-sdk-6.0-source-built-artifacts' for glob 'dotnet*' Note, selecting 'dotnet-apphost-pack-3.1' for glob 'dotnet*' Note, selecting 'dotnet-apphost-pack-6.0' for glob 'dotnet*' Note, selecting 'dotnet-runtime-6.0' for glob 'dotnet*' Package 'dotnet' is not installed, so not removed Package 'dotnet-nightly' is not installed, so not removed Package 'dotnet-sdk-6.0-source-built-artifacts' is not installed, so not removed Package 'dotnet-templates-6.0' is not installed, so not removed Package 'dotnet-apphost-pack-3.1' is not installed, so not removed Package 'dotnet-hostfxr-3.1' is not installed, so not removed Package 'dotnet-runtime-deps-3.1' is not installed, so not removed Package 'dotnet-runtime-deps-6.0' is not installed, so not removed The following packages were automatically installed and are no longer required: aspnetcore-targeting-pack-6.0 liblttng-ust-common1 liblttng-ust-ctl5 liblttng-ust1 libunwind-13 netstandard-targeting-pack-2.1 Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED: aspnetcore-runtime-6.0 dotnet-apphost-pack-6.0 dotnet-host dotnet-hostfxr-6.0 dotnet-runtime-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0 dotnet6 0 upgraded, 0 newly installed, 8 to remove and 11 not upgraded. After this operation, 474 MB disk space will be freed. Do you want to continue? [Y/n] y (Reading database ... 72398 files and directories currently installed.) Removing dotnet6 (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-sdk-6.0 (6.0.400-1) ... Removing aspnetcore-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-apphost-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-hostfxr-6.0 (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-host (6.0.108-0ubuntu1~22.04.1) ... Removing dotnet-targeting-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... ➜ ~ sudo apt install dotnet6 Reading package lists... Done Building dependency tree... Done Reading state information... Done The following additional packages will be installed: aspnetcore-runtime-6.0 dotnet-apphost-pack-6.0 dotnet-host dotnet-hostfxr-6.0 dotnet-runtime-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0 The following NEW packages will be installed: aspnetcore-runtime-6.0 dotnet-apphost-pack-6.0 dotnet-host dotnet-hostfxr-6.0 dotnet-runtime-6.0 dotnet-sdk-6.0 dotnet-targeting-pack-6.0 dotnet6 0 upgraded, 8 newly installed, 0 to remove and 11 not upgraded. Need to get 124 MB of archives. After this operation, 474 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-targeting-pack-6.0 amd64 6.0.108-0ubuntu1~22.04.1 [2238 kB] Get:2 https://packages.microsoft.com/ubuntu/22.04/prod jammy/main amd64 dotnet-sdk-6.0 amd64 6.0.400-1 [86.4 MB] Get:3 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-host amd64 6.0.108-0ubuntu1~22.04.1 [156 kB] Get:4 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-hostfxr-6.0 amd64 6.0.108-0ubuntu1~22.04.1 [154 kB] Get:5 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-runtime-6.0 amd64 6.0.108-0ubuntu1~22.04.1 [23.7 MB] Get:6 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 aspnetcore-runtime-6.0 amd64 6.0.108-0ubuntu1~22.04.1 [8090 kB] Get:7 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet-apphost-pack-6.0 amd64 6.0.108-0ubuntu1~22.04.1 [3735 kB] Get:8 http://archive.ubuntu.com/ubuntu jammy-updates/universe amd64 dotnet6 amd64 6.0.108-0ubuntu1~22.04.1 [20.5 kB] Fetched 124 MB in 7s (17.2 MB/s) Selecting previously unselected package dotnet-targeting-pack-6.0. (Reading database ... 68662 files and directories currently installed.) Preparing to unpack .../0-dotnet-targeting-pack-6.0_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet-targeting-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package dotnet-host. Preparing to unpack .../1-dotnet-host_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet-host (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package dotnet-hostfxr-6.0. Preparing to unpack .../2-dotnet-hostfxr-6.0_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet-hostfxr-6.0 (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package dotnet-runtime-6.0. Preparing to unpack .../3-dotnet-runtime-6.0_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package aspnetcore-runtime-6.0. Preparing to unpack .../4-aspnetcore-runtime-6.0_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking aspnetcore-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package dotnet-apphost-pack-6.0. Preparing to unpack .../5-dotnet-apphost-pack-6.0_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet-apphost-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... Selecting previously unselected package dotnet-sdk-6.0. Preparing to unpack .../6-dotnet-sdk-6.0_6.0.400-1_amd64.deb ... Unpacking dotnet-sdk-6.0 (6.0.400-1) ... Selecting previously unselected package dotnet6. Preparing to unpack .../7-dotnet6_6.0.108-0ubuntu1~22.04.1_amd64.deb ... Unpacking dotnet6 (6.0.108-0ubuntu1~22.04.1) ... Setting up dotnet-host (6.0.108-0ubuntu1~22.04.1) ... update-alternatives: using /usr/lib/dotnet/dotnet6-6.0.108/dotnet to provide /usr/bin/dotnet (dotnet) in auto mode update-alternatives: warning: skip creation of /usr/share/bash-completion/completions/dotnet because associated file /usr/lib/dotnet/dotnet6-6.0.108/bash-completion/completions/dotnet (of link group dotnet) doesn't exist Setting up dotnet-apphost-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... Setting up dotnet-targeting-pack-6.0 (6.0.108-0ubuntu1~22.04.1) ... Setting up dotnet-hostfxr-6.0 (6.0.108-0ubuntu1~22.04.1) ... Setting up dotnet-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Setting up aspnetcore-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ... Setting up dotnet-sdk-6.0 (6.0.400-1) ... This software may collect information about you and your use of the software, and send that to Microsoft. Please visit http://aka.ms/dotnet-cli-eula for more information. Welcome to .NET! --------------------- Learn more about .NET: https://aka.ms/dotnet-docs Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs Telemetry --------- The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell. Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry Configuring... -------------- A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once. Setting up dotnet6 (6.0.108-0ubuntu1~22.04.1) ... Scanning processes... Scanning processor microcode... Scanning linux images... Failed to retrieve available kernel versions. Failed to check for processor microcode upgrades. No services need to be restarted. No containers need to be restarted. No user sessions are running outdated binaries. No VM guests are running outdated hypervisor (qemu) binaries on this host. ➜ ~ dotnet --list-sdks ➜ ~ dotnet build The command could not be loaded, possibly because: * You intended to execute a .NET application: The application 'build' does not exist. * You intended to execute a .NET SDK command: No .NET SDKs were found. Download a .NET SDK: https://aka.ms/dotnet-download Learn about SDK resolution: https://aka.ms/dotnet/sdk-not-found ```

Am I missing something?

omajid commented 2 years ago

@FilBot3 Thanks for the install log. It shows this bit:

Setting up aspnetcore-runtime-6.0 (6.0.108-0ubuntu1~22.04.1) ...
Setting up dotnet-sdk-6.0 (6.0.400-1) ...

The first package here is from the Ubuntu repositories. The second is from packages.microsoft.com. You are in a mixed state and that's why things don't work. See "Mixed state scenario 1" or "Mixed state scenario 2" from the top post in this issue and follow that advice.

FilBot3 commented 2 years ago

Ah,yeah. Removing the microsoft-prod deb source and updating helped.

sudo apt remove dotnet\*
sudo rm /etc/apt/sources.iist.d/microsoft-prod.list
sudo apt update
sudo apt install -y dotnet6

However, I may have a similar issue on Fedora next...

omajid commented 2 years ago

For Fedora, see https://docs.microsoft.com/en-us/dotnet/core/install/linux-package-mixup#solutions

FilBot3 commented 2 years ago

Yup, same thing on Fedora.

sudo rm /etc/yum.repos.d/microsoft-prod.repo
sudo dnf remove dotnet\*
sudo dnf install dotnet-sdk-6.0

I am fixed now.

squallshaw commented 2 years ago

Tried the steps but to no avail. Ubuntu 22.04

$ dn --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

I resolve the same problem by installing runtimes first then SDK. I run "sudo apt install aspnetcore-runtime-6.0" first, then run "sudo apt install dotnet6".

FilBot3 commented 2 years ago

Tried the steps but to no avail. Ubuntu 22.04

$ dn --info

global.json file:
  Not found

Host:
  Version:      6.0.8
  Architecture: x64
  Commit:       55fb7ef977

.NET SDKs installed:
  No SDKs were found.

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

I resolve the same problem by installing runtimes first then SDK. I run "sudo apt install aspnetcore-runtime-6.0" first, then run "sudo apt install dotnet6".

Did you uninstall the previous installations of dotnet you had? Did you also remove any mention of the microsoft-prod.repo or source for Ubuntu?

squallshaw commented 2 years ago

Yes,I uninstall all the things you mention before I did this. But if I install dotnet6 first I would confront the same problem no matter I do the clean up or not. So just install runtime first work for me for this particular issue.

khteh commented 2 years ago

Ah,yeah. Removing the microsoft-prod deb source and updating helped.

sudo apt remove dotnet\*
sudo rm /etc/apt/sources.iist.d/microsoft-prod.list
sudo apt update
sudo apt install -y dotnet6

However, I may have a similar issue on Fedora next...

How to install libmsquic if packages.microsoft.com/keys/microsoft.asc is removed? https://learn.microsoft.com/en-us/windows-server/administration/linux-package-repository-for-microsoft-software

richlander commented 2 years ago

@khteh -- These related instructions (linked from the top) for PowerShell might help: https://github.com/dotnet/core/issues/7713.

truthadjuster commented 2 years ago

I have dotnet in an older previous Ubuntu, and then I updated to Ubuntu Jammy 22.04. After this, dotnet --list-sdks no longer return anything. So I have to fix it by:

sudo apt remove dotnet*
sudo apt remove aspnetcore*
sudo rm /etc/apt/sources.list.d/microsoft-prod.list*
sudo apt update
sudo apt install dotnet6

And it is fixed now.

miroljub1995 commented 2 years ago

Will you ever support SDK 6.0.401 via Jammy feed? I like the simplicity of Jammy feed, but I also need latest SDK.