fix: switched from default host builder to avoid directory scan on Linux

This commit is contained in:
Dylan R. E. Moonfire 2021-09-12 00:29:47 -05:00
parent 9aaed2ee20
commit e59d489a06

View file

@ -49,14 +49,31 @@ namespace MfGames.ToolBuilder
this.loggingService.Configure(arguments); this.loggingService.Configure(arguments);
// Start up the basic configuration. // Start up the basic configuration.
this.hostBuilder = Host //
.CreateDefaultBuilder(arguments) // Normally, we would use Host.CreateDefaultBuilder(args) to create
// this, but when run as a stand-alone application in someone's
// $HOME on Linux, this causes an inotify watcher to be registered
// on the entire directory tree (which takes a really long time).
//
// We also don't need most of the default features.
this.hostBuilder =
new HostBuilder()
.UseDefaultServiceProvider(
(context, options) =>
{
bool isDevelopment =
context.HostingEnvironment.IsDevelopment();
options.ValidateScopes = isDevelopment;
options.ValidateOnBuild = isDevelopment;
})
.UseConsoleLifetime() .UseConsoleLifetime()
.ConfigureAppConfiguration(this.ConfigureAppConfiguration) .ConfigureAppConfiguration(this.ConfigureAppConfiguration)
.UseSerilog() .UseSerilog()
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) .UseServiceProviderFactory(
new AutofacServiceProviderFactory())
.ConfigureServices(this.ConfigureServices) .ConfigureServices(this.ConfigureServices)
.ConfigureContainer<ContainerBuilder>(this.ConfigureContainer); .ConfigureContainer<ContainerBuilder>(
this.ConfigureContainer);
} }
/// <summary> /// <summary>