Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

Expand Down Expand Up @@ -43,7 +44,8 @@ public static Task RunFirefoxServerLoopAsync(ProxyOptions options, string[] args
public static async Task RunDevToolsProxyAsync(ProxyOptions options, string[] args, ILoggerFactory loggerFactory, CancellationToken token)
{
string proxyUrl = $"http://127.0.0.1:{options.DevToolsProxyPort}";
IWebHost host = new WebHostBuilder()
IHost host = new HostBuilder().ConfigureWebHost(webHostBuilder =>
webHostBuilder
.UseSetting("UseIISIntegration", false.ToString())
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
Expand All @@ -60,7 +62,7 @@ public static async Task RunDevToolsProxyAsync(ProxyOptions options, string[] ar
config.AddCommandLine(args);
})
.UseUrls(proxyUrl)
.Build();
).Build();

if (token.CanBeCanceled)
token.Register(async () => await host.StopAsync());
Expand Down
5 changes: 3 additions & 2 deletions src/mono/wasm/host/BrowserHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Threading.Tasks;
using System.Web;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.WebAssembly.AppHost.DevServer;
using Microsoft.WebAssembly.Diagnostics;
Expand Down Expand Up @@ -80,7 +81,7 @@ private async Task RunAsync(ILoggerFactory loggerFactory, CancellationToken toke
? aspnetUrls.Split(';', StringSplitOptions.RemoveEmptyEntries)
: new string[] { $"http://127.0.0.1:{_args.CommonConfig.HostProperties.WebServerPort}", "https://127.0.0.1:0" };

(ServerURLs serverURLs, IWebHost host) = await StartWebServerAsync(_args,
(ServerURLs serverURLs, IHost host) = await StartWebServerAsync(_args,
urls,
token);

Expand All @@ -100,7 +101,7 @@ private async Task RunAsync(ILoggerFactory loggerFactory, CancellationToken toke
await host.WaitForShutdownAsync(token);
}

private async Task<(ServerURLs, IWebHost)> StartWebServerAsync(BrowserArguments args, string[] urls, CancellationToken token)
private async Task<(ServerURLs, IHost)> StartWebServerAsync(BrowserArguments args, string[] urls, CancellationToken token)
{
Func<WebSocket, Task>? onConsoleConnected = null;
if (args.ForwardConsoleOutput ?? false)
Expand Down
9 changes: 5 additions & 4 deletions src/mono/wasm/host/DevServer/DevServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ namespace Microsoft.WebAssembly.AppHost.DevServer;

internal static class DevServer
{
internal static async Task<(ServerURLs, IWebHost)> StartAsync(DevServerOptions options, ILogger logger, CancellationToken token)
internal static async Task<(ServerURLs, IHost)> StartAsync(DevServerOptions options, ILogger logger, CancellationToken token)
{
TaskCompletionSource<ServerURLs> realUrlsAvailableTcs = new();

IWebHostBuilder builder = new WebHostBuilder()
IHostBuilder builder = new HostBuilder().ConfigureWebHost(webHostBuilder =>
webHostBuilder
.UseConfiguration(ConfigureHostConfiguration(options))
.UseKestrel()
.UseStaticWebAssets()
Expand All @@ -47,10 +48,10 @@ internal static class DevServer
services.AddSingleton(realUrlsAvailableTcs);
services.AddRouting();
})
.UseUrls(options.Urls);
.UseUrls(options.Urls));


IWebHost? host = builder.Build();
IHost? host = builder.Build();
await host.StartAsync(token);

if (token.CanBeCanceled)
Expand Down
9 changes: 5 additions & 4 deletions src/mono/wasm/host/WebServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ namespace Microsoft.WebAssembly.AppHost;

public class WebServer
{
internal static async Task<(ServerURLs, IWebHost)> StartAsync(WebServerOptions options, ILogger logger, CancellationToken token)
internal static async Task<(ServerURLs, IHost)> StartAsync(WebServerOptions options, ILogger logger, CancellationToken token)
{
TaskCompletionSource<ServerURLs> realUrlsAvailableTcs = new();

IWebHostBuilder builder = new WebHostBuilder()
IHostBuilder builder = new HostBuilder().ConfigureWebHost(webHostBuilder =>
webHostBuilder
.UseKestrel()
.UseStartup<WebServerStartup>()
.ConfigureLogging(logging =>
Expand All @@ -49,12 +50,12 @@ public class WebServer
services.AddSingleton(realUrlsAvailableTcs);
services.AddRouting();
})
.UseUrls(options.Urls);
.UseUrls(options.Urls));

if (options.ContentRootPath != null)
builder.UseContentRoot(options.ContentRootPath);

IWebHost? host = builder.Build();
IHost? host = builder.Build();
await host.StartAsync(token);

if (token.CanBeCanceled)
Expand Down
Loading