skip to Main Content

I had the dotnet sdk working just fine yesterday, today when I login to my PC, I update the system and VSCode and then when I tried running dotnet watch run, I got this error:

  * You intended to execute a .NET application:
      The application 'watch' 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

Here is what happens when I try to do an apt install of the sdk(It shows already installed):

sudo apt install dotnet-sdk-6.0
[sudo] password for robinson: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
dotnet-sdk-6.0 is already the newest version (6.0.400-1).
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.

Here is my dotnet --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]

From my googling, it seems it may be PATH issue, but I tried adding a few different paths and it still didn’t work.
here is the which dotnet:

/usr/bin/dotnet

And my echo path:

/home/robinson/.nvm/versions/node/v18.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/robinson/.dotnet/tools

I’m a linux noob, any help is appreciated. I’m running popOS on an x64 computer.

9

Answers


  1. Chosen as BEST ANSWER

    So I ended up solving the issue as well by doing the following: I uninstalled everything I could that was dotnet related with: sudo apt remove 'dotnet*' Then I did a sudo apt autoremove and sudo apt update.

    Then I followed the instructions on this link to unpack the binaries straight into the /opt/ folder. Once I added the necessary lines to PATH (according to the instructions in the link), everything worked as expected.

    I would however recommend following the instructions by Saranga first as using the package manager might be the better solution. Thank you everyone.


  2. I had the same problem, and here’s what I did to resolve it.

    1. Removed all .NET packages
      sudo apt remove 'dotnet*'
      sudo apt remove 'aspnetcore*'

    2. Deleted PMC repository from APT, by deleting the repo .list file
      sudo rm /etc/apt/sources.list.d/microsoft-prod.list

    3. Ran sudo apt update

    4. Installed .NET 6 SDK via sudo apt install dotnet-sdk-6.0

    This is one of the solutions provided on the Github issues page for dotnet/core, please follow the original article if the above did not work for you.
    https://github.com/dotnet/core/issues/7699

    Login or Signup to reply.
  3. Check list of dotnet versions installed on your machine and check for other than the SDK, if any other dotnet sdk/runtime is installed on your machine.

    dotnet --list-sdks
    

    If there is multiple dotnet versions installed, theres a chance your default dotnet version is pointing to other versions, So change it

    dotnet new globaljson --sdk-version 6.0.400-1 --force
    

    Also you use the dotnet-core-uninstall tool to remove the not-required version of dotnet to get rid of the version issue. Note that you have to install it manually as it not part of the sdk/runtime.

    dotnet -core-uninstall --all-previews-but-latest --sdk
    
    Login or Signup to reply.
  4. There is some package version issue, use this to get dotnet-sdk working again

    Update

    Dotnet is now part of some ubuntu repo and there are glitches on dist upgrading ubuntu, using https://github.com/dotnet/core/issues/7699#issuecomment-1288131522 removes the ms repo, its packages and installs dotnet from the canonical repo.

    sudo snap remove dotnet-sdk
    sudo apt remove 'dotnet*'
    sudo apt remove 'aspnetcore*'
    sudo apt remove 'netstandard*'
    sudo rm /etc/apt/sources.list.d/microsoft-prod.list
    sudo rm /etc/apt/sources.list.d/microsoft-prod.list.save
    sudo apt update
    sudo apt install dotnet6
    

    Old

    $ sudo apt install aspnetcore-runtime-6.0=6.0.8-1 dotnet-apphost-pack-6.0=6.0.8-1 dotnet-host=6.0.8-1 dotnet-hostfxr-6.0=6.0.8-1 dotnet-runtime-6.0=6.0.8-1 dotnet-sdk-6.0=6.0.400-1 dotnet-targeting-pack-6.0=6.0.8-1
    

    I hope that will be fixed soon. 🤞

    https://github.com/dotnet/core/issues/7699 brings some light into the issue.

    Login or Signup to reply.
  5. in my case it was already installed, but it did not recognize it because it was in another location apparently.

    https://learn.microsoft.com/es-es/dotnet/core/install/linux-snap
    

    According to the documentation, I installed it through snap and this was the solution with this command

    sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet
    

    in UBUNTU 22.04, .NET6.0

    Login or Signup to reply.
  6. Seems to be an issue with the latest version, i just removed dotnet entirely and reinstalled dotnet sdk 6.0 and everything is working again.
    Be sure to use sudo apt install dotnet-sdk-6.0 to specify the 6.0 version and not the latest

    Login or Signup to reply.
  7. Here’s what I did to fix it:

    Removed all .NET packages

    sudo apt remove 'dotnet*'

    sudo apt remove 'aspnetcore*'

    Deleted PMC repository from APT, by deleting the repo .list file

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

    Ran

    sudo apt update

    Installed .NET 6 SDK via the install script:

    (follow the instructions carefully!)

    https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install

    Modified my ~/.bashrc so at the end of the file it has:

    export PATH="$PATH:/home/INSERT_YOUR_USERNAME_HERE/.dotnet"

    Now everything is working again.

    Login or Signup to reply.
  8. You need to setup your DOTNET_ROOT according to Base Path: /usr/share/dotnet/sdk/7.0.101/

    osanhaji@5CD2068Y53:~ $ dotnet --info
    .NET SDK:
     Version:   7.0.101
     Commit:    bb24aafa11
    
    Runtime Environment:
     OS Name:     ubuntu
     OS Version:  22.04
     OS Platform: Linux
     RID:         ubuntu.22.04-x64
     Base Path:   /usr/share/dotnet/sdk/7.0.101/
    
    Host:
      Version:      7.0.1
      Architecture: x64
      Commit:       97203d38ba
    
    .NET SDKs installed:
      7.0.101 [/usr/share/dotnet/sdk]
    
    .NET runtimes installed:
      Microsoft.AspNetCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 7.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
    
    Other architectures found:
      None
    
    Environment variables:
      DOTNET_ROOT       [/usr/share/dotnet/]
    
    global.json file:
      Not found
    
    Learn more:
      https://aka.ms/dotnet/info
    
    Download .NET:
      https://aka.ms/dotnet/download
    
    
    osanhaji@5CD2068Y53:~ $ export DOTNET_ROOT=/usr/share/dotnet/
    
    
    Login or Signup to reply.
  9. Even after fully uninstalling according to the instructions, I had /etc/profile.d/dotnet.sh pointing DOTNET_ROOT to /usr/lib/dotnet. I modified the file to point to /usr/share/dotnet. That fixed the issue for me. I guess the full uninstall didn’t fully uninstall .NET.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search