I updated my ASP.NET Core project to .NET Core v3.0.0-preview3, and I now get:
Startup.cs(75,50,75,69): warning CS0618: \'IHostingEnvironment\' is o
When
Microsoft.Extensions.Hostingwas introduced in 2.1 some types likeIHostingEnvironmentandIApplicationLifetimewere copied fromMicrosoft.AspNetCore.Hosting. Some 3.0 changes cause apps to include both theMicrosoft.Extensions.HostingandMicrosoft.AspNetCore.Hostingnamespaces. Any use of those duplicate types causes an "ambiguous reference" compiler error when both namespaces are referenced.This error has been addressed in 3.0.0-preview3 by marking the following types obsolete and replacing them with new types. There have not been any behavioral changes made for the new types, only naming.
Obsolete types (warning):
Microsoft.Extensions.Hosting.IHostingEnvironment
Microsoft.AspNetCore.Hosting.IHostingEnvironment
Microsoft.Extensions.Hosting.IApplicationLifetime
Microsoft.AspNetCore.Hosting.IApplicationLifetime
Microsoft.Extensions.Hosting.EnvironmentName
Microsoft.AspNetCore.Hosting.EnvironmentNameNew types:
Microsoft.Extensions.Hosting.IHostEnvironment
Microsoft.AspNetCore.Hosting.IWebHostEnvironment : IHostEnvironment
Microsoft.Extensions.Hosting.IHostApplicationLifetime
Microsoft.Extensions.Hosting.EnvironmentsNote the new IHostEnvironment IsDevelopment, IsProduction, etc. extension methods are in the Microsoft.Extensions.Hosting namespace which may need to be added to your app.
For 3.0 both the old and new types will be available from HostBulder's and WebHostBuilder's dependency injection containers. The old types will be removed in 4.0.
Source: https://github.com/aspnet/AspNetCore/issues/7749
Long and short, you're looking for IWebHostEnvironment now. You'll likely need to add using for Microsoft.Extensions.Hosting as well.