[Breaking change]: WebApplicationBuilder
gives ASPNET_
-prefixed environment variables lower precedence
#498
Labels
WebApplicationBuilder
gives ASPNET_
-prefixed environment variables lower precedence
#498
Description
Starting in .NET 7 preview 3, when using
WebApplicationBuilder
but not any other host (e.g.ConfigureWebHostDefaults
orWebHost.CreateDefaultBuilder
), command-line arguments andDOTNET_
-prefixed environment variables overrideASPNET_
-prefixed environment variables when reading from default host configuration sources which are used to read host variables like the content root path and environment name when theWebApplicationBuilder
is constructed and serves as a base for application configuration.ASPNET_
-prefixed environment variables now has the lowest precedence of all ofWebApplicationBuilder
's default host configuration sources.See dotnet/AspNetCore.Docs#25626 (comment) for more context.
Version
.NET 7 Preview 3
Previous behavior
ASPNET_
-prefixed environment variables overrode command-line arguments andDOTNET_
-prefixed environment variables.New behavior
Command-line arguments and
DOTNET_
-prefixed environment variables overrideASPNET_
-prefixed environment variablesType of breaking change
Reason for change
To prevent environment variables from overriding explicit command-line arguments when reading host variables which is more consistent with application configuration which has always given command-line arguments the highest precedence.
Recommended action
If you were using
ASPNETCORE_
-prefixed environment variables to override command-line arguments orDOTNET_-
prefixed environment variables, use something with a higher priority. This could mean using custom WebApplicationOptions which overrides all default hosting configuration sources.Affected APIs
Microsoft.AspNetCore.Builder.WebApplicationBuilder
The text was updated successfully, but these errors were encountered: