Skip to content
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

Update CreateSlimBuilder to use Host.CreateEmptyApplicationBuilder. #46579

Merged
merged 3 commits into from
Feb 16, 2023

Conversation

eerhardt
Copy link
Member

Also fix 2 existing bugs:

  1. ContentRootPath is set to the app's BaseDirectory, and not CurrentWorkingDirectory. Default to CWD by using the same logic as HostApplicationBuilder.
  2. Add un-prefixed environment variables to the configuration, and ensure the configuration order is the same as WebApplication.CreateBuilder.

Fix #46293

Also fix 2 existing bugs:
1. ContentRootPath is set to the app's BaseDirectory, and not CurrentWorkingDirectory. Default to CWD by using the same logic as HostApplicationBuilder.
2. Add un-prefixed environment variables to the configuration, and ensure the configuration order is the same as WebApplication.CreateBuilder.

Fix dotnet#46293
@ghost ghost added the area-runtime label Feb 11, 2023
@eerhardt eerhardt added area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-runtime labels Feb 11, 2023
@eerhardt eerhardt self-assigned this Feb 11, 2023
@eerhardt
Copy link
Member Author

@halter73 - any feedback here?

// add the default host configuration sources, so they are picked up by the HostApplicationBuilder constructor.
// These won't be added by HostApplicationBuilder since DisableDefaults = true.
// SetDefaultContentRoot needs to be added between 'ASPNETCORE_' and 'DOTNET_' in order to match behavior of the non-slim WebApplicationBuilder.
SetDefaultContentRoot(options, configuration);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do this before adding any configuration, right? SetDefaultContentRoot tries not to override any explicit config, so order shouldn't really matter. If we do it first, we could probably get rid of configuration[HostDefaults.ContentRootKey] is null, but I understand keeping it the same for consistency.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it probably could, but I like keeping the logic consistent, so if we ever need to update one it would be straight forward to update the other.

@eerhardt eerhardt merged commit e0f2d09 into dotnet:main Feb 16, 2023
@eerhardt eerhardt deleted the UseEmptyBuilder branch February 16, 2023 22:41
@ghost ghost added this to the 8.0-preview2 milestone Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-frameworks *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update CreateSlimBuilder for Microsoft.Extensions.Hosting.Host.CreateEmptyApplicationBuilder
2 participants