HostBuilder replaces WebHostBuilder
MODIFY
WalletWasabi.Backend/Extensions.cs
WalletWasabi.Backend/Extensions.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -14,10 +15,10 @@ namespace WalletWasabi.Backend
where T : class, IStartupTask
=> services.AddTransient<IStartupTask, T>();
- public static async Task RunWithTasksAsync(this IWebHost webHost, CancellationToken cancellationToken = default)
+ public static async Task RunWithTasksAsync(this IHost host, CancellationToken cancellationToken = default)
{
- await Task.WhenAll(webHost.Services.GetServices<IStartupTask>().Select(t => t.ExecuteAsync(cancellationToken)));
- await webHost.RunAsync(cancellationToken);
+ await Task.WhenAll(host.Services.GetServices<IStartupTask>().Select(t => t.ExecuteAsync(cancellationToken)));
+ await host.RunAsync(cancellationToken);
}
}
}

MODIFY
WalletWasabi.Backend/Program.cs
WalletWasabi.Backend/Program.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
using NBitcoin;
using NBitcoin.RPC;
using System;
@@ -23,10 +24,12 @@ namespace WalletWasabi.Backend
{
var endPoint = "http://localhost:37127/";
- using var host = WebHost.CreateDefaultBuilder(args)
+ var host = Host.CreateDefaultBuilder(args)
+ .ConfigureWebHostDefaults(webBuilder => webBuilder
.UseStartup<Startup>()
- .UseUrls(endPoint)
+ .UseUrls(endPoint))
.Build();
+
await host.RunWithTasksAsync();
}
catch (Exception ex)

MODIFY
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
WalletWasabi.Tests/XunitConfiguration/RegTestFixture.cs
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Hosting;
using NBitcoin;
using NBitcoin.RPC;
using System;
@@ -21,7 +22,7 @@ namespace WalletWasabi.Tests.XunitConfiguration
public class RegTestFixture : IDisposable
{
public string BackendEndPoint { get; internal set; }
- public IWebHost BackendHost { get; internal set; }
+ public IHost BackendHost { get; internal set; }
public CoreNode BackendRegTestNode { get; internal set; }
public Backend.Global Global { get; }
@@ -57,12 +58,15 @@ namespace WalletWasabi.Tests.XunitConfiguration
.AddInMemoryCollection(new[] { new KeyValuePair<string, string>("datadir", testnetBackendDir) })
.Build();
BackendEndPoint = $"http://localhost:{new Random().Next(37130, 38000)}/";
- BackendHost = WebHost.CreateDefaultBuilder()
+
+ BackendHost = Host.CreateDefaultBuilder()
+ .ConfigureWebHostDefaults(webBuilder => webBuilder
.UseStartup<Startup>()
.UseConfiguration(conf)
.UseWebRoot("../../../../WalletWasabi.Backend/wwwroot")
- .UseUrls(BackendEndPoint)
+ .UseUrls(BackendEndPoint))
.Build();
+
Global = (Backend.Global)BackendHost.Services.GetService(typeof(Backend.Global));
var hostInitializationTask = BackendHost.RunWithTasksAsync();
Logger.LogInfo($"Started Backend webhost: {BackendEndPoint}");

HostBuilder replaces WebHostBuilder