HostApplicationBuilderSettings.Args respected by HostApplicationBuilder ctor
The HostApplicationBuilder constructor that accepts a HostApplicationBuilderSettings object now applies the HostApplicationBuilderSettings.Args property, regardless of whether DisableDefaults is set to true
or false
.
Version introduced
.NET 8 Preview 2
Previous behavior
Previously, the HostApplicationBuilderSettings.Args property was ignored when HostApplicationBuilderSettings.DisableDefaults was set to true
.
New behavior
Starting in .NET 8, the HostApplicationBuilderSettings.Args value is added to HostApplicationBuilder.Configuration regardless of whether DisableDefaults is set to true
or false
.
Type of breaking change
This change is a behavioral change.
Reason for change
The behavior of ignoring HostApplicationBuilderSettings.Args was unexpected, even when HostApplicationBuilderSettings.DisableDefaults was set to true
. That's because if the caller didn't want the command-line arguments applied to the HostApplicationBuilder, they wouldn't have set them on the HostApplicationBuilderSettings object. Since the caller did pass the command-line arguments on the settings, those arguments should be respected.
Recommended action
If you don't want the command-line arguments to be added to the HostApplicationBuilder configuration, leave the HostApplicationBuilderSettings.Args property set to null
.