I have a .net 5.0 web api application. I want to publish build it to run it on a windows server 2019.
I build it locally in commandline using "dotnet run --launch-profile CMDLINE" CMDLINE is one of my profile in my launchSettings.json
I then try to publish my app with the following command.
I then try "dotnet application.dll"
in an attempt to run the dll localy.
the application seems to be started but when I try to access my public endpoint (returning a string with tag [Anonymous] doesn't require authentication, then I get the error 500 in postman
My project is always compiling in /debug/net5.0/ or in /debug/net5.0/publish/
Am I missing an essential step please help. I basically want to give my build/released application to my system admin, which is going to publish the API on a windows server 2019.
He just told me that running "dotnet application.dll" is not working as expected. (never publish an app on a custom server like this before, always used online hosting.)
I finally noticed my hosting environment wasn't the same as my specified ASPNETCORE_ENVIRONMENT variable in my launchsettings.json!
I simply specified my hosting environment in commandline with "set ASPNETCORE_ENVIRONMENT=Staging" and built it up with "dotnet application.dll --launch-profile CMDLINE" and it worked. "dotnet application.dll" is also working.