Search code examples
.netvisual-studio-codesdk

VS Code doesn't find expected dotnet SDK


I am running VS Code on Linux Mint ( 21.1 Vera ). I am developing a small dotnet web app using C#.

Everything was running fine until ( I believe ) there was a dotnet sdk update.

I can see the current dotnet version from the terminal: 7.0.302

dotnet --list-sdks
7.0.302 [/usr/share/dotnet/sdk]

When trying to run or build the project that was working until the update, I get this message:

dotnet run

You must install or update .NET to run this application.

App: /usr/share/dotnet/sdk/7.0.302/dotnet.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '7.0.5' (x64)
.NET location: /usr/share/dotnet/

No frameworks were found.

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&    framework_version=7.0.5&arch=x64&rid=linuxmint.21.1-x64

So I follow the last link to install the missing framework.

It eventually takes to a command to install the SDK:

sudo apt-get update && \ sudo apt-get install -y dotnet-sdk-7.0

It doesn't let me specify 7.0.5, so it just reinstalls the most recent version, which is 7.0.302, and I am back to square one.

I have found a command to install 7.0.5 specifically, but it throws an error:

./dotnet-install.sh --architecture x64 --install-dir /usr/share/dotnet/ --runtime dotnet --version 7.0.5

dotnet_install: Error: Failed to verify the version of installed `.NET Core Runtime`.
Installation source: https://dotnetcli.azureedge.net/dotnet/Runtime/7.0.5/dotnet-runtime-7.0.5-linux-x64.tar.gz.
Installation location: /usr/share/dotnet/.
Report the bug at https://github.com/dotnet/install-scripts/issues.
dotnet_install: Error: `.NET Core Runtime` with version = 7.0.5 failed to install with an error.

It doesn't find a .NET runtime because I don't have one installed ( and never have ). But, from what I understand, SDK already included a runtime?

Ideally I would like to just tell VS Code to use 7.0.302, but happy to stick to 7.0.5 if I can find it anywhere. I still haven't managed...

Can anyone suggest a solution?


Solution

  • I found the solution to the problem a few minutes after posting the issue...

    The steps that worked for me are from https://github.com/dotnet/core/issues/7699

    The steps are from mixed state scenario 1. Copied here in case the link is no longer available in the future:

    Remove all .NET packages

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

    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
    

    Update APT

    sudo apt update
    

    Install .NET SDK 6.0

    sudo apt install dotnet-sdk-6.0