-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Environment variables still affect DebugProxy #20308
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
Comments
I see what you mean.
Could you remove that provider in ConfigureHostConfiguration? |
Also, I suggest switching from ConfigureWebHostDefaults to ConfigureWebHost. It won't completely remove this issue, but it will give you the lowest level of control. |
I tried, but it didn't seem feasible because by the time Also it's not feasible for |
Update: @Tratcher and I discussed this on a call and after some debugging, came to the conclusion that since we want to eliminate all inheritance of ASP.NET-related env vars from parent to child, it's not desirable to work around this using Suggested plan:
|
Yes, I'll prep a PR for this. |
Filed #20328 for 5.0 |
I was getting some errors when trying to launch the debugger on my machine - Kestrel couldn't start because it said something was already listening on the same port. It appears to be because the debug proxy is still trying to inherit environment variables from the parent process.
By putting a breakpoint on the following line in
DebugProxyHost.cs
, it's possible to confirm that theEnvironmentVariablesConfigurationProvider
is still being used:It looks like this is because both
GenericWebHostBuilder
andWebHostBuilder
(not certain which is used in this case) are hardcoded to call.AddEnvironmentVariables(prefix: "ASPNETCORE_")
in their constructors.As such I'm not sure what is the recommended pattern for not loading config from environment variables. @Tratcher - do you have any suggestions?
I investigated to see if we could remove the
EnvironmentVariablesConfigurationProvider
after the builder is created, but that's not easy since by the timeConfigureAppConfiguration
gets called, that provider is already nested several levels deep inChainedConfigurationSource
instances, which seems to be immutable.If nothing else works we could go back to our previous pattern of removing all environment variables that start with the
ASPNETCORE_
prefix before launching the debug proxy, but cc @captainsafia for any other ideas.The text was updated successfully, but these errors were encountered: