-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
different paths for system with ASPNETCORE_ENVIRONMENT set and without it #124
Comments
The code was added because the application structure has some differences between when we develop and when we run it in production (non-development). Are you setting the ASPNETCORE_ENVIRONMENT variable system wide on your development servers and if so what value are you using? |
@jimmyca15 But with this configuration Microsoft.IIS.Administration can't start when registered as service. |
@kae Saying that, I would avoid using system wide environment variables, unless absolutely necessary. I suppose your goal is to setup particular environment for your applications/services, not the entire system? Globally set ASPNETCORE_ENVIRONMENT could likely effect (unexpectedly) any app/service that uses ASP.NET Core on that machine. A recommended approach is to add ASPNETCORE_ENVIRONMENT before starting your app/service. For services it's handy to configure using the service regkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\YourServiceName Add value Add any environment variables as follows: Hope it can help unblock you for now. |
@drago-draganov Missing ASPNETCORE_ENVIRONMENT lead to using production settings from configs in dev environment, which is really inconvinient and considered dangerous by us. Thats why our choice was global system settings. |
Thanks for reporting it, @kae ! Do you configure and run all of your ASP.NET Core apps as IIS web applications, or they are standalone windows services? |
@drago-draganov |
Then you may be able to use HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC to configure ASPNETCORE_ENVIRONMENT for all ASP.NET Core applications that are hosted in IIS. The problem with global ASPNETCORE_ENVIRONMENT is well outlined by your scenario. Consider 3rd party or system services that can suddenly start behaving unexpectedly, because they will see Development config/settings. For them it's production environment. We eliminated the dependency of ASPNETCORE_ENVIRONMENT in IIS Administration API. An official build will follow shortly. Thanks for pointing out the issue. Appreciate it! |
Thanks, will try your solution |
@kae @drago-draganov I moved the issue that was created at the bottom of #59 to here.
https://github.com/Microsoft/IIS.Administration/blob/dev/src/Microsoft.IIS.Administration/ConfigurationHelper.cs#L21
This code gets different paths for system with ASPNETCORE_ENVIRONMENT set and without it
So on development servers it's going to get default service directory and throw exception of not finding config directory.
Is there any sensible reason for not just using
Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
on all systems?The text was updated successfully, but these errors were encountered: