Closed RyanThomas73 closed 3 years ago
The library as is is this:
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="[2.1.0,4.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[2.1.0,4.0)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="[2.1.0,4.0)" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="[2.1.0,4.0)" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="[3.0.0,4.0.0)" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="[3.0.0,4.0.0)" />
<PackageReference Include="Microsoft.Extensions.Options" Version="[3.0.0,4.0.0)" />
</ItemGroup>
The assumption is that if you were targeting ASP.Net Core 3.1, then your library would use netstandard2.1.
I didn't want to cut off support for ASP.Net Core 2.* at the time (and probably still don't).
The problem is the netstandard2.1 is referencing Microsoft.AspNetCore.Hosting.Abstractions which is discontinued / not supported for netstandard2.1. The netstandard2.1 version needs to reference Microsoft.Extensions.Hosting.Abstractions only (which only has abstractions for IHost(Builder) now not IWebHost(Builder)).
So that is one option. Target the correct extension library that does support netstandard2.1 and remove the extension methods targeting WebHostBuilder.
If you wish to maintain the extension methods targeting WebHostBuilder it will need to target netcoreapp3.
That's a good point about targeting the runtimes instead of netstandard**** for the adapter library. I can't ditch WebHostBuilder support though, that'd be screaming from different folks.
This should be addressed by Lamar v4.3.1
Lamar.Microsoft.DependencyInjection
contains a package reference toMicrosoft.AspNetCore.Hosting.Abstractions
.The latter is no longer published via nuget, the last published version being
v2.2.0
which was publishes almost 2 years ago. See https://www.nuget.org/packages/Microsoft.AspNetCore.Hosting.Abstractions/. Newer versions beyond that (e.gv3.1.0
) ship directly with the net core target framework.Including this dependency creates version conflicts when used in applications targeting later net core runtimes. For example:
The library should be switched to referencing the
Microsoft.Extensions.Hosting.Abstractions
package and/or multi targeting the different netcoreapp frameworks to ensure that the correct dependencies are used and that runtime signature differences do not occur.