Skip to content
代码片段 群组 项目
提交 92409e2e 编辑于 作者: Pranav K's avatar Pranav K
浏览文件

Make the dev-server log less (#18971)

* Make the dev-server log less
* Allow loading a user configured settings file

上级 31f63d9e
No related branches found
No related tags found
无相关合并请求
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
<ItemGroup> <ItemGroup>
<NuspecProperty Include="publishDir=$(PublishDir)" /> <NuspecProperty Include="publishDir=$(PublishDir)" />
<NuspecProperty Include="componentsrootdir=..\..\..\" /> <NuspecProperty Include="componentsrootdir=..\..\..\" />
<NuspecProperty Include="blazorversion=$(PackageVersion)" />
</ItemGroup> </ItemGroup>
</Project> </Project>
// Copyright (c) .NET Foundation. All rights reserved. // Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
{ {
...@@ -27,17 +25,21 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server ...@@ -27,17 +25,21 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.DevServer.Server
/// </summary> /// </summary>
public static IHost BuildWebHost(string[] args) => public static IHost BuildWebHost(string[] args) =>
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureHostConfiguration(cb => { .ConfigureHostConfiguration(config =>
{
var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).FirstOrDefault(); var applicationPath = args.SkipWhile(a => a != "--applicationpath").Skip(1).FirstOrDefault();
var name = Path.ChangeExtension(applicationPath,".StaticWebAssets.xml"); var applicationDirectory = Path.GetDirectoryName(applicationPath);
var name = Path.ChangeExtension(applicationPath, ".StaticWebAssets.xml");
if (name != null) var inMemoryConfiguration = new Dictionary<string, string>
{ {
cb.AddInMemoryCollection(new Dictionary<string, string> ["Logging:LogLevel:Microsoft"] = "Warning",
{ ["Logging:LogLevel:Microsoft.Hosting.Lifetime"] = "Information",
[WebHostDefaults.StaticWebAssetsKey] = name [WebHostDefaults.StaticWebAssetsKey] = name,
}); };
}
config.AddInMemoryCollection(inMemoryConfiguration);
config.AddJsonFile(Path.Combine(applicationDirectory, "blazor-devserversettings.json"), optional: true, reloadOnChange: true);
}) })
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>
{ {
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册