Linux Server Can't Run ASP.NET using dotnet Command

181 Views Asked by At

I installed .NET 7.0.3 on my Linux Server.

I also deployed a few MVC websites in .NET 7.0.0 behind an Apache reverse proxy.

But when I run dotnet <DLL NAME>.dll, It is saying it can't find a framework

enter image description here

If I check the install status, I can see it is properly installed

enter image description here

The fun thing is, While I was unable to run any of my ASP.NET Core app using dotnet <DLL NAME>.dll command,

If I hit URL in a browser, Apache is able to proxy to it and I can see the website content. Why this is happening?

Here's a VIDEO DEMONSTRATION

YouTube: https://www.youtube.com/watch?v=yJkIasUPWzU

2

There are 2 best solutions below

2
Luke On

You have the .NET CLI installed, but that's not the only thing you need to run .NET binaries.

dotnet --info is telling us you don't have any runtimes or SDKs installed. At a minimum you need to install the .NET 7.0.0 Runtime using the link provided to you in the error message: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=7.0.0&arch=x64&rid=ubuntu.22.04-x64

3
Teoman Tıngır On

Microsoft.AspNetCore.App is not the .net core runtime. It is a metadata package for .net core runtime libraries. So you are missing actual runtime library which should called Microsoft.NETCore.App.

When you run the the dotnet --list-runtimes you need to see following output. In your case only the first one (metadata package) will be available.

Microsoft.AspNetCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

So you need to install correct runtime package from here microsoft .net platform