Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/FeatherHttp/WebApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Reflection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting.StaticWebAssets;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -228,7 +229,7 @@ public IHostBuilder ConfigureHostConfiguration(Action<IConfigurationBuilder> con
_environment.ApplicationName = config[HostDefaults.ApplicationKey] ?? _environment.ApplicationName;
_environment.ContentRootPath = config[HostDefaults.ContentRootKey] ?? _environment.ContentRootPath;
_environment.EnvironmentName = config[HostDefaults.EnvironmentKey] ?? _environment.EnvironmentName;
_environment.ResolveFileProviders();
_environment.ResolveFileProviders(config);
_configuration.ChangeBasePath(_environment.ContentRootPath);

_operations += b => b.ConfigureHostConfiguration(configureDelegate);
Expand Down Expand Up @@ -312,7 +313,7 @@ public IWebHostBuilder UseSetting(string key, string value)
else if (key == WebHostDefaults.ContentRootKey)
{
_environment.ContentRootPath = value;
_environment.ResolveFileProviders();
_environment.ResolveFileProviders(_configuration);

_configuration.ChangeBasePath(value);
}
Expand All @@ -323,7 +324,7 @@ public IWebHostBuilder UseSetting(string key, string value)
else if (key == WebHostDefaults.WebRootKey)
{
_environment.WebRootPath = value;
_environment.ResolveFileProviders();
_environment.ResolveFileProviders(_configuration);
}

_operations += b => b.UseSetting(key, value);
Expand Down Expand Up @@ -361,13 +362,18 @@ public WebHostEnvironment(Assembly callingAssembly)
WebRootPath = wwwroot;
}

ResolveFileProviders();
ResolveFileProviders(new Configuration());
}

public void ResolveFileProviders()
public void ResolveFileProviders(IConfiguration configuration)
{
ContentRootFileProvider = Directory.Exists(ContentRootPath) ? (IFileProvider)new PhysicalFileProvider(ContentRootPath) : new NullFileProvider();
WebRootFileProvider = WebRootPath != null && Directory.Exists(Path.Combine(ContentRootPath, WebRootPath)) ? (IFileProvider)new PhysicalFileProvider(Path.Combine(ContentRootPath, WebRootPath)) : new NullFileProvider();

if (this.IsDevelopment())
{
StaticWebAssetsLoader.UseStaticWebAssets(this, configuration);
}
}

public IFileProvider WebRootFileProvider { get; set; }
Expand Down