'ConfigureServices returning a System.IServiceProvider isn't supported.'

Startup syntax has changed for configuring Autofac for ASP.NET Core 3.0+

In addition to using the following on the host builder

.UseServiceProviderFactory(new AutofacServiceProviderFactory())

In Startup do the following format

public void ConfigureServices(IServiceCollection services) {
    //... normal registration here

    // Add services to the collection. Don't build or return
    // any IServiceProvider or the ConfigureContainer method
    // won't get called.

    services.AddControllers();
}

// ConfigureContainer is where you can register things directly
// with Autofac. This runs after ConfigureServices so the things
// here will override registrations made in ConfigureServices.
// Don't build the container; that gets done for you. If you
// need a reference to the container, you need to use the
// "Without ConfigureContainer" mechanism shown later.
public void ConfigureContainer(ContainerBuilder builder) {
    // Register your own things directly with Autofac
    builder.AddMyCustomService();

    //...
}

Reference Autofac documentation for ASP.NET Core 3.0+


Instead of Host in Program.cs you can use WebHost

public class Program
{
  public static void Main(string[] args)
  {
    CreateWebHostBuilder(args).Build().Run();
  }

  public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
      .UseStartup<Startup>();
}

In this case following code works

public IServiceProvider ConfigureServices(IServiceCollection services)
{
  ...
  var builder = new ContainerBuilder();

  builder.Populate(services);
  var container = builder.Build();
  return new AutofacServiceProvider(container);
}