IWebHostingEnvironment is not available in .NET Core 2.x, but in 3.x it's the recommended way to access the host environment with threat of IHostingEnvironment being removed in the future. This can be a problem in libraries that need to run both on 2.x and 3.x.
The following tries to mask the differences in a multi-targeted .NET Core project by creating a custom IWebHostEnvironment implementations that picks up values from IHostingEnvironment in 2.x.
#if NETCORE2
using Microsoft.Extensions.FileProviders;
namespace Microsoft.AspNetCore.Hosting
{