Skip to content

Environment variables still affect DebugProxy #20308

@SteveSandersonMS

Description

@SteveSandersonMS

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 the EnvironmentVariablesConfigurationProvider is still being used:

image

It looks like this is because both GenericWebHostBuilder and WebHostBuilder (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 time ConfigureAppConfiguration gets called, that provider is already nested several levels deep in ChainedConfigurationSource 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.

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions