I see that there is support for ASP.NET Core 3.0 but what about 3.1? I've tried with no luck. Not sure if I am doing something dumb or if it is not supported?
I've installed the latest Nuget Packages:
And I am using:
var builder = new WebHostBuilder();
builder.UseLamar()
The file includes using Lamar.Microsoft.DependencyInjection;
at the top.
But getting error: 'WebHostBuilder' does not contain a definition for 'UseLamar'.
The Integration with ASP.Net Core guide includes a note that states:
If you are targeting .Net Core 3.0 and/or
netstandard2.1
, use the newly consolidated HostBuilder instead of the previousIWebHostBuilder
.
A literal replacement for the code shown in the question would look like this:
var builder = new HostBuilder();
builder.UseLamar();
However, the typical setup code for creating a host builder, with a call to UseLamar
added, would look something like this for 3.0+:
Host.CreateDefaultBuilder(args)
.UseLamar()
.ConfigureWebHostDefaults(webHostBuilder =>
{
webHostBuilder.UseStartup<Startup>();
});
The note I called out above links to the ASP.NET Core docs, which explains the generic host in much more detail: .NET Generic Host.