ubuntuwindows-subsystem-for-linux.net-8.0.net-core-2.1

Installing .NET Core 2.1 SDK in parallel to .NET 8


I am following below commands to install .NET Core 2.1 SDK

Enable Microsoft PPA

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

Installing .NET Core 2.1 SDK

sudo apt update 
sudo apt install apt-transport-https 
sudo apt install dotnet-sdk-2.1 

I already have .NET 8 installed in wsl ubuntu 20.04,

I get following error when I execute the command:

sudo apt install dotnet-sdk-2.1

error installing dotnetcore

root@LP003060:/mnt/c/nitin/JavaCallCSharp_new# sudo apt install dotnet-sdk-2.1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 dotnet-host-8.0 : Conflicts: dotnet-host
 dotnet-runtime-deps-2.1 : Depends: libssl1.0.0 but it is not installable or
                                    libssl1.0.2 but it is not installable or
                                    libssl1.1 but it is not installable
                           Depends: liblttng-ust0 but it is not installable
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Solution

  • According to .NET SDK on Ubuntu documentation, versions 8.0 and 2.1 are available from Microsoft repository at date today for Ubuntu 20.04.

    Probably you should uninstall dotnet-host-8.0 which conflicts and is no longer needed according to the following setup (just reproduced in ubuntu 20.04 on wsl).

    source /etc/os-release
    wget https://packages.microsoft.com/config/$ID/$VERSION_ID/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    apt update
    apt-get install -y dotnet-sdk-8.0
    apt install dotnet-sdk-2.1
    

    Following sequence passes without conflict and here is resulting package list where dotnet-host-8.0 is not visible:

    # dpkg -l | grep dotnet
    ii  dotnet-apphost-pack-8.0        8.0.8-1                      amd64        Microsoft.NETCore.App.Host 8.0.8
    ii  dotnet-host                    8.0.8-1                      amd64        Microsoft .NET Host - 8.0.8
    ii  dotnet-hostfxr-2.1             2.1.30-1                     amd64        Microsoft .NET Core Host FX Resolver - 2.1.30 2.1.30
    ii  dotnet-hostfxr-8.0             8.0.8-1                      amd64        Microsoft .NET Host FX Resolver - 8.0.8
    ii  dotnet-runtime-2.1             2.1.30-1                     amd64        Microsoft .NET Core Runtime - 2.1.30 Microsoft.NETCore.App 2.1.30
    ii  dotnet-runtime-8.0             8.0.8-1                      amd64        Microsoft.NETCore.App.Runtime 8.0.8
    ii  dotnet-runtime-deps-2.1        2.1.30-1                     amd64        dotnet-runtime-deps-2.1 2.1.30
    ii  dotnet-runtime-deps-8.0        8.0.8-1                      amd64        dotnet-runtime-deps-debian 8.0.8
    ii  dotnet-sdk-2.1                 2.1.818-1                    amd64        Microsoft .NET Core SDK 2.1.818
    ii  dotnet-sdk-8.0                 8.0.401-1                    amd64        Microsoft .NET SDK 8.0.401
    ii  dotnet-targeting-pack-8.0      8.0.8-1                      amd64        Microsoft.NETCore.App.Ref 8.0.8
    

    As a result, I recommend you uninstall dotnet-host-8.0 first and reinstall dotnet-sdk-8.0 which depends on dotnet-host instead.