'ASP.NET CORE web application doesn't use .css styles when run using dotnet command

I have a ASP .NET CORE application, targeted in verion 6.0. When I run it from Visual Studio it looks great, but when I run it using dotnet command:

dotnet webApplication1.dll

it looks like no .css styles or .js scripts where found and used. I searched this documentation but cannot find the hint how to include styles path.



Solution 1:[1]

I solved it by manually copying wwwroot folder to the \bin\Debug\net6.0 directory. For some reasons it is not being copied there automatically.

Solution 2:[2]

I think you are using the wrong command You should use.

dotnet run

If you want to use the dotnet command you should publish you app before in order to have all the misc files.

You need to do :

dotnet publish

Before running the app using

dotnet Webapp.dll

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user3057544
Solution 2 khalid bourzayq