Skip to content

Commit 089598b

Browse files
committed
Allow loading a user configured settings file
1 parent 6d94870 commit 089598b

File tree

1 file changed

+11
-13
lines changed
  • src/Components/Blazor/DevServer/src/Server

1 file changed

+11
-13
lines changed

src/Components/Blazor/DevServer/src/Server/Program.cs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,21 @@ public class Program
2525
/// </summary>
2626
public static IHost BuildWebHost(string[] args) =>
2727
Host.CreateDefaultBuilder(args)
28-
.ConfigureHostConfiguration(cb =>
28+
.ConfigureHostConfiguration(config =>
2929
{
3030
var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).FirstOrDefault();
31-
var name = Path.ChangeExtension(applicationPath,".StaticWebAssets.xml");
31+
var applicationDirectory = Path.GetDirectoryName(applicationPath);
32+
var name = Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml");
3233

33-
if (name != null)
34+
var inMemoryConfiguration = new Dictionary<string, string>
3435
{
35-
cb.AddInMemoryCollection(new Dictionary<string, string>
36-
{
37-
[WebHostDefaults.StaticWebAssetsKey] = name
38-
});
39-
}
40-
})
41-
.ConfigureLogging(logging =>
42-
{
43-
logging.SetMinimumLevel(LogLevel.Warning);
44-
logging.AddFilter("Microsoft.Hosting.Lifetime", LogLevel.Information);
36+
["Logging:LogLevel:Microsoft"] = "Warning",
37+
["Logging:LogLevel:Microsoft.Hosting.Lifetime"] = "Information",
38+
[WebHostDefaults.StaticWebAssetsKey] = name,
39+
};
40+
41+
config.AddInMemoryCollection(inMemoryConfiguration);
42+
config.AddJsonFile(Path.Combine(applicationDirectory, "blazor-devserversettings.json"), optional: true, reloadOnChange: true);
4543
})
4644
.ConfigureWebHostDefaults(webBuilder =>
4745
{

0 commit comments

Comments
 (0)