Workaround an error when building in ProdCon where the RuntimeFrameworkVersion is overridden externally. Generally, the error is good, but when --no-restore is specified, we are okay ignoring this verification.
- Today the request services middleware is responsible for making sure there are request scoped services.
This PR tries introduces some breaking changes that are hopefully acceptable in order to gain some performance.
- Here are the assumptions this PR makes:
- Since this middleware is first in the pipeline, the only thing that can
set a default service provider would be the server itself. Since we have no servers that do that
I removed that code that tries to noop if there's an existing service provider.
- This PR no longer restores the previous service provider feature since it gets replaced every request
anyways. Kestrel also clears out the feature on each request so it shouldn't be a problem (in theory).
Once again, since this middleware is first, it is the last thing that runs before the server re-gains
control on the way out so there's no need to restore anything.
- We use the RegisterForDispose method to dispose of the IServiceProvider instead of doing it inline.
- Use the IServiceProviderFactory<IServiceCollection>
- Assert creation and disposal service providers
- Updated the tests to verify that service providers are created and disposed
- Called CreateBuilder even in the default case in case the service collection is modified as part of it.
- The goal here is to enable components that use hosting abstractions to use
the web host. It lets us start to decouple components from the web host abstractions
where possible while not breaking any existing components. This will allow things
to work in both the generic host and the web host. The one snafu is the WebHostBuilderContext
which has an IHostingEnvironment typed as the AspNetCore.Abstractions type.
- Updated tests.
#1218