1
1
// Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using System ;
5
4
using System . Collections . Generic ;
6
- using System . Diagnostics ;
7
5
using System . IO ;
8
6
using System . Linq ;
9
- using System . Threading ;
10
7
using Microsoft . AspNetCore . Hosting ;
11
8
using Microsoft . Extensions . Configuration ;
12
9
using Microsoft . Extensions . Hosting ;
10
+ using Microsoft . Extensions . Logging ;
13
11
14
12
namespace Microsoft . AspNetCore . Components . WebAssembly . DevServer . Server
15
13
{
@@ -27,17 +25,21 @@ public class Program
27
25
/// </summary>
28
26
public static IHost BuildWebHost ( string [ ] args ) =>
29
27
Host . CreateDefaultBuilder ( args )
30
- . ConfigureHostConfiguration ( cb => {
28
+ . ConfigureHostConfiguration ( config =>
29
+ {
31
30
var applicationPath = args . SkipWhile ( a => a != "--applicationpath" ) . Skip ( 1 ) . FirstOrDefault ( ) ;
32
- var name = Path . ChangeExtension ( applicationPath , ".StaticWebAssets.xml" ) ;
31
+ var applicationDirectory = Path . GetDirectoryName ( applicationPath ) ;
32
+ var name = Path . ChangeExtension ( applicationPath , ".StaticWebAssets.xml" ) ;
33
33
34
- if ( name != null )
34
+ var inMemoryConfiguration = new Dictionary < string , string >
35
35
{
36
- cb . AddInMemoryCollection ( new Dictionary < string , string >
37
- {
38
- [ WebHostDefaults . StaticWebAssetsKey ] = name
39
- } ) ;
40
- }
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 ) ;
41
43
} )
42
44
. ConfigureWebHostDefaults ( webBuilder =>
43
45
{
0 commit comments