Difference between two dotnet cli commands: dotnet "app.dll" vs dotnet run "app.dll"

1.7k Views Asked by At

I found little weird worth asking the community and get an understanding.

I have Dotnet Core 5.0 Web Application as well as Dotnet Core 5.0 Web API Project. Both are plain vanilla coming straight from Visual Studio 2019 boilerplate template.

I press both one after another from visual studio (press F5 by kipping as default) and make sure it works.

  1. Web Application gives home page while
  2. Web Api gives the swagger output for WeatherForecast API

Now, I want to test the same using Visual Studio Command Prompt through Dotnet CLI command.

First, I tried with Web Application. I navigated to the path I have Web Application and I execute dotnet "bin\debug\net5.0\webapp01.dll" and it ran. I can see the web application in my browser. So far so good.

Second, I tried with Web API. I navigated to the path I have Web API and I executed dotnet "bin\debug\net5.0\webapi01.dll" and it ran. I opened the browser and check the same swagger page and OOPS. 404 error page. nothing is coming. I checked the command prompt and it's still running but no output.

Alternatively (while I troubleshooting), I gave tried to execute dotnet run command for Web API dotnet run "bin\debug\net5.0\webapi01.dll" - interestingly it prints an additional line in the command prompt than the previous (without run command) one - the line was "Building..." rest everything as is. I checked the browser with the same swagger link and voila - it's giving me an output.

Well - to check I did the same with Web Application dotnet run "bin\debug\net5.0\webapp01.dll" - that also works with the correct output.

This leads me to ask the questions?

  1. If we should use dotnet "dll" then why is it not working for the web API project?
  2. What is so different running dotnet "dll vs dotnet run "dll"?
0

There are 0 best solutions below