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
.UseConsoleLifetime() // this, but when run as a stand-alone application in someone's
.ConfigureAppConfiguration(this.ConfigureAppConfiguration) // $HOME on Linux, this causes an inotify watcher to be registered
.UseSerilog() // on the entire directory tree (which takes a really long time).
.UseServiceProviderFactory(new AutofacServiceProviderFactory()) //
.ConfigureServices(this.ConfigureServices) // We also don't need most of the default features.
.ConfigureContainer<ContainerBuilder>(this.ConfigureContainer); this.hostBuilder =
new HostBuilder()
.UseDefaultServiceProvider(
(context, options) =>
{
bool isDevelopment =
context.HostingEnvironment.IsDevelopment();
options.ValidateScopes = isDevelopment;
options.ValidateOnBuild = isDevelopment;
})
.UseConsoleLifetime()
.ConfigureAppConfiguration(this.ConfigureAppConfiguration)
.UseSerilog()
.UseServiceProviderFactory(
new AutofacServiceProviderFactory())
.ConfigureServices(this.ConfigureServices)
.ConfigureContainer<ContainerBuilder>(
this.ConfigureContainer);
} }
/// <summary> /// <summary>