It appears that in ASP.NET 5 RC1, the ASPNET_ENV environment variable was changed to Hosting:Environment. http://docs.asp.net/en/latest/fundamentals/environments.html should be updated to reflect the change.
It seems to be Hosting:Environment for Windows and Hosting__Environment (Note the double underscore) for Linux and OSX according to IHostingEnvironment.
Is that correct? Why have different names based on the OS? Also this issue seems to indicate that a single underscore is the correct name.
... on the same subject (referring to http://docs.asp.net/en/latest/fundamentals/environments.html#determining-the-environment-at-runtime ), it might be good to mention setting the environment (outside of Program:Main) isn't a good idea per https://github.com/aspnet/dnx/issues/3214#issuecomment-160432649. I think explicitly showing how to set it in code with Program:Main would be good for those cases where the app should detect its environment on its own (no config files) and set the env var itself. Info provided later by @davidfowl in https://github.com/aspnet/dnx/issues/3214#issuecomment-160432649 indicates that this setting cannot be made in code early enough to be reliable.
The variables are changing again post RC1 so I wouldn't change asp_env just yet
@davidfowl - What are they changing to?
I have an application that ignores "Hosting:Environment" but accepts "ASPNET_ENV" at the moment.
It is an RC 2 application.
I have another application which I created using ASP.NET Tools RC1 Update 1 templates and it just works fine with "Hosting:Environment".
Do you have any clue?
We should update the RC1 docs and then track changing this again for RC2.
Now its decided that Hosting:Environment is no longer and ASPNET_ENVIRONMENT is the replacement is it time for the change? I tried to do a search to see how much work it would be but for some reason github search removes colon which gives me way to many hits for Hosting:Environment From browsing I know its in a lot of places.
Also is it visual studio that creates launchSettings.json If so is a tooling update required
The tooling has been updated, it's just not released yet :smile:. It's also not Hosting:Enviroment post RC1.
Just out of interest will we see a tooling update with RC2?
Yes, there's always a tooling update paired with major releases.
Setting ASPNET_ENVIRONMENT appears to do nothing at all. I always see Hosting environment: Production as of several versions ago. I'm running on the latest dev packages. Can anyone shed some light on this?
@optlink Posting a sample solution would be most helpful.
Here is a simple solution I updated to the latest RC2 build that exhibits the same issue: WebApplication2.zip
@optlink Sounds like you're hitting the tooling bug when tooling gets out of sync with launchSettings.json
When this happens launchSettings.json can show APNET_ENVIRONMENT but the tooling and the launch are using Hosting:Environment. When it gets to this stage because Hosting:Environment is no longer valid it defaults to Production.
I am not sure of the exact scenarios where it happens but I have seen it more than once on my machine.
If you reset the variable in the GUI it should work again.
Yes, that was the issue. Thank you very much, that one has been bugging me for a while.
@davidfowl The title of this issue is no longer correct as things are moving to ASPNET_ENVIRONMENT. Probably best to close to save confusion
Closing this issue as we will be moving to ASPNET_ENVIRONMENT
Note to those who stumble across this thread. It has changed to ASPNETCORE_ENVIRONMENTin RC2.
Most helpful comment
Note to those who stumble across this thread. It has changed to
ASPNETCORE_ENVIRONMENTin RC2.