I have some code from a web app that configures the http client to use a certificate. I relies on IHttpClientBuilder and AddHttpClient.
I'd like to use the same methods for testing in a console app, but I'm struggling to even get those types be available there.
The documentation here says I can use Microsoft.Extensions.Hosting in a console app (there it's used to initialize configuration), but even though this package is supposed to depend on Microsoft.Extensions.DependencyInjection, where above types and methods are supposed to live, the compiler tells me those types are unknown.
The console app is freshly created with .NET 6.0 and it's only package reference is Microsoft.Extensions.Hosting at 6.0.1. Why does that not give me IHttpClientBuilder?
EDIT:
After
dotnet new console
dotnet add package Microsoft.Extensions.Hosting
edit only Program.cs to
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var host = Host.CreateDefaultBuilder(args);
host.ConfigureServices(services =>
{
services.AddHttpClient(); // not found
});
to find that IHttpClientBuilder and friends are still not there.