Search code examples
c#.net-corecentos.net-standard

The framework 'Microsoft.NETCore.App', version '5.0.13' was not found


at the terminal of CentOS 8, I try to run the following:

dotnet -h

Error message:

The framework 'Microsoft.NETCore.App', version '5.0.13' was not found.

I have no idea of what is happening.

enter image description here

I have tried lots of instructions around the Google. Some of the steps that I have tried is as follow:

https://learn.microsoft.com/en-us/dotnet/core/versions/selection\

https://learn.microsoft.com/en-us/dotnet/core/install/linux-centos

https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-run

sudo dnf install dotnet-sdk-5.0
sudo dnf install aspnetcore-runtime-5.0
sudo dnf install dotnet-runtime-5.0

I also tried Enable snaps on CentOS and install .NET Runtime 5.0

https://snapcraft.io/install/dotnet-runtime-50/centos

sudo yum install epel-release
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
sudo snap install dotnet-runtime-50

but none of this resolve the problem.


Update: Jan 26th 2022

Enter the following command:

dotnet --info

will get the following message:

dotnet --info

Then, I follow this steps explained at:

https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup

by uninstalling and reinstalling the dotnet

sudo dnf remove packages-microsoft-prod
sudo dnf remove 'dotnet*' 'aspnet*' 'netstandard*'
sudo dnf install dotnet-sdk-5.0

then, I try the following:

dotnet --info

the system says something like (forget to screenshot):

dotnet cannot be found at
/user/var/bin/.... dotnet...
(I forget the exact path)

This is taking too much time to fix... that I have a more important task to do. I end up giving up to do further debugging this error. I deleted the CentOS and reinstall a brand new clean CentOS and start all over again. I believe I must have messed up multiple conflicting dotnet version and multiple error caching.

I will post another update once I have completed reinstalling new CentOS.


Update 2: Jan 26th 2022 (Fixed)

Ok guys, the problem is fixed. By combining all the tips that you have provided, here is what I have done:

First, do a new clean installation of CentOS 8

Proceed to install the "dotnet"

sudo dnf install dotnet-sdk-3.1
sudo dnf install dotnet-sdk-5.0

Test by running a console app:

dotnet ConsoleApp2.dll

Everything works perfectly fine now. Thank you very much for your time and help.


Solution

  • Multiple source of dotnet runtime and sdk had been installed. This resulting multiple conflicting binary path and assembly caching crash.

    Step 1: Do a clean installation of CentOS

    Step 2: Install required runtime version, for example:

    sudo dnf install dotnet-sdk-3.1
    sudo dnf install dotnet-sdk-5.0
    

    Step 3: Test by running a console app:

    dotnet ConsoleApp.dll
    

    done.


    Update: Alternative 2: Run the app without CentOS installing any runtime

    Another alternative option is to publish the .NET Core Project as "self-contained" into single binary.

    enter image description here

    Here is the example of how it looks like after publishing, there is only 1 single file:

    enter image description here

    Copy the compiled binary to CentOS

    At the terminal, browse to the folder that contains the self-contained binary, for example:

    cd /home/admin/testapp
    

    Next, is to allow execution permission to the file:

    sudo chmod 777 ConsoleApp2
    

    Execute the app:

    ./ConsoleApp2