public IWebHostBuilder UseSetting(string key, string value) { _settings[key] = value; if (key == WebHostDefaults.ApplicationKey) { _environment.ApplicationName = value; } else if (key == WebHostDefaults.ContentRootKey) { _environment.ContentRootPath = value; _environment.ResolveFileProviders(_configuration); _configuration.ChangeBasePath(value); } else if (key == WebHostDefaults.EnvironmentKey) { _environment.EnvironmentName = value; } else if (key == WebHostDefaults.WebRootKey) { _environment.WebRootPath = value; _environment.ResolveFileProviders(_configuration); } _operations += b => b.UseSetting(key, value); return(this); }
public IHostBuilder ConfigureHostConfiguration(Action <IConfigurationBuilder> configureDelegate) { // HACK: We need to evaluate the host configuration as they are changes so that we have an accurate view of the world configureDelegate(_hostConfiguration); var config = _hostConfiguration.Build(); _environment.ApplicationName = config[HostDefaults.ApplicationKey] ?? _environment.ApplicationName; _environment.ContentRootPath = config[HostDefaults.ContentRootKey] ?? _environment.ContentRootPath; _environment.EnvironmentName = config[HostDefaults.EnvironmentKey] ?? _environment.EnvironmentName; _environment.ResolveFileProviders(config); _configuration.ChangeBasePath(_environment.ContentRootPath); _operations += b => b.ConfigureHostConfiguration(configureDelegate); return(this); }