Closed
Description
Describe the bug
Background
I am using IHostingStartup within my package library as it is used by external users to create the web host, targets NET 4.6 and NET Core 3.1. I set the builder setting HostingStartupAssembliesKey to package library assembly FullName
I have added a feature to add use an instanced startup class instead of using the normal UseStartup. It is a custom interface, not Microsoft.AspNetCore.Hosting.IStartup
The intention is for testing, to make an easier way of testing different services, rather than separate startup classes.
Bug
- When using the Microsoft.AspNetCore.Hosting.WebHostBuilderExtensions.Configure method (I add the method of the instanced startup), the extension method sets WebHostBuilder setting ApplicationKey to startup assembly. This was not correct as it was setting to the package library, using assembly Name
public static IWebHostBuilder Configure(this IWebHostBuilder hostBuilder, Action<WebHostBuilderContext, IApplicationBuilder> configureApp)
- When I do host.Build(), the method:
private IServiceCollection BuildCommonServices(out AggregationException hostingStartupErrors)
create WebHostOptions, which registers 2x hosting startup assemblies because of Name and FullName
To Reproduce
- Use IHostingStartup, using assembly FullName
- Use WebHostBuilder.Configure
- Run WebHost.Build()
Exceptions (if any)
I found the issue that Swashbuckle raised an exception that a document was already registered.
Further technical details
- NET 4.6.1, NET Core 3.1