Repro steps:
Expected:
Project rrcore1 (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hosting environment: Development
Content root path: C:\Git\rrcore1
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
Actual:
Project rrcore1 (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hosting environment: Production
Content root path: C:\Git\rrcore1
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
You need to setup enviroment variable before run debug mode. See disscussion #73.
In a fact from console you need to specify your specif Env name via flag:
dotnet run --environment="QA" or dotnet run --environment="DEV"
You may also set it globally for your machine via
set ASPNETCORE_ENVIRONMENT=DEV
SETting the environment variable seems to work, but dotnet run --environment="DEV" is not working. Can you point me to info about the --environment argument?
As far as I'm aware ASPNETCORE_ENVIRONMENT is the correct way to specify the environment, as per docs at https://docs.asp.net/en/latest/fundamentals/environments.html.
In my tests, dotnet run's --configuration parameter had no effect on ASP.NET Core (not just the NodeServices library, but all of ASP.NET Core). If anyone has reason to believe that --configuration (or --environment) is supposed to do something, please let us know!
--environment works for me to change to Development , staging or production but I had a problem setting it manually inside the launchsettings.json which wasn't used and always on production.
I'm logging the following in my App window when debugging:
Application start in environment: Development (from injected IHostingEnvironment) <= My own NLog call to Console
Hosting environment: Production <= Don't understand why this default text doesn't pick up Development?
Content root path: <= Don't understand why this is empty
Now listening on: http://localhost:5001
See the instructions about how to set ASPNETCORE_ENVIRONMENT in various ways (depending on your dev environment) by searching for ASPNETCORE_ENVIRONMENT in this blog post: https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/
This also matches the asp.net docs about configuring the environment: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments
@SteveSandersonMS Thanks for replying! I do have that set and when I look at my injected IHostingEnvironment I get the expected environment (Development). It's just confusing that the built-in Console.WriteLine on startup says "Hosting environment: Production" when it's not true.
the dotnet run --environment="X" flag only seems to work if you have added .AddCommandLine(args) to your ConfigurationBuilder in Program.cs.
Have a look at this:
https://andrewlock.net/how-to-set-the-hosting-environment-in-asp-net-core/#setting-hosting-environment-using-command-args
Most helpful comment
You need to setup enviroment variable before run debug mode. See disscussion #73.
In a fact from console you need to specify your specif Env name via flag:
dotnet run --environment="QA"ordotnet run --environment="DEV"You may also set it globally for your machine via
set ASPNETCORE_ENVIRONMENT=DEV