Hi,
I'm having this issue after updating my system to .Net Core 3.0

I need to dynamically create ocelot.json base on my environment but I'm getting this error
"cannot convert from Microsoft.Extension.Hosting.IHostEnvironment to Microsoft.AspNetCore.Host.IWebHostEnvironment"
I find out that ocelot is still using IWebHostBuilder which is for .Net core 2.x instead of IHostBuilder that comes with .Net cor 3.0.
Thanks in advance
You can use ConfigureWebHostDefaults to do that.
Here is a sample that you can take a look.
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://*:9000")
.ConfigureAppConfiguration((hostingContext, config) =>
{
config
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
config.AddOcelot("your folder", hostingContext.HostingEnvironment);
})
.ConfigureServices(services =>
{
services.AddOcelot();
})
.Configure(app =>
{
app.UseOcelot().Wait();
});
});
You can use
ConfigureWebHostDefaultsto do that.Here is a sample that you can take a look.
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseUrls("http://*:9000") .ConfigureAppConfiguration((hostingContext, config) => { config .SetBasePath(hostingContext.HostingEnvironment.ContentRootPath) .AddJsonFile("ocelot.json") .AddEnvironmentVariables(); config.AddOcelot("your folder", hostingContext.HostingEnvironment); }) .ConfigureServices(services => { services.AddOcelot(); }) .Configure(app => { app.UseOcelot().Wait(); }); });
Thanks, you've saved my day.
Most helpful comment
You can use
ConfigureWebHostDefaultsto do that.Here is a sample that you can take a look.