3 using System
.Threading
;
4 using System
.Threading
.Tasks
;
5 using Microsoft
.AspNetCore
;
6 using Microsoft
.AspNetCore
.Hosting
;
7 using Microsoft
.Extensions
.Configuration
;
8 using Microsoft
.AspNetCore
.Builder
;
9 using Microsoft
.Extensions
.DependencyInjection
;
11 namespace WebAssembly
.Net
.Debugging
13 public class ProxyOptions
{
14 public Uri DevToolsUrl { get; set; }
= new Uri ("http://localhost:9222");
17 public class TestHarnessOptions
: ProxyOptions
{
18 public string ChromePath { get; set; }
19 public string AppPath { get; set; }
20 public string PagePath { get; set; }
21 public string NodeApp { get; set; }
24 public class Program
{
25 public static void Main(string[] args
)
27 var host
= new WebHostBuilder()
28 .UseSetting ("UseIISIntegration", false.ToString ())
30 .UseContentRoot (Directory
.GetCurrentDirectory())
31 .UseStartup
<Startup
> ()
32 .ConfigureAppConfiguration ((hostingContext
, config
) =>
34 config
.AddCommandLine(args
);
36 .UseUrls ("http://localhost:9300")
43 public class TestHarnessProxy
{
46 static CancellationTokenSource cts
= new CancellationTokenSource ();
47 static object proxyLock
= new object ();
49 public static readonly Uri Endpoint
= new Uri ("http://localhost:9400");
51 public static Task
Start (string chromePath
, string appPath
, string pagePath
)
57 host
= WebHost
.CreateDefaultBuilder ()
58 .UseSetting ("UseIISIntegration", false.ToString ())
59 .ConfigureAppConfiguration ((hostingContext
, config
) => {
60 config
.AddEnvironmentVariables (prefix
: "WASM_TESTS_");
62 .ConfigureServices ((ctx
, services
) => {
63 services
.Configure
<TestHarnessOptions
> (ctx
.Configuration
);
64 services
.Configure
<TestHarnessOptions
> (options
=> {
65 options
.ChromePath
= options
.ChromePath
?? chromePath
;
66 options
.AppPath
= appPath
;
67 options
.PagePath
= pagePath
;
68 options
.DevToolsUrl
= new Uri ("http://localhost:0");
71 .UseStartup
<TestHarnessStartup
> ()
72 .UseUrls (Endpoint
.ToString ())
74 hostTask
= host
.StartAsync (cts
.Token
);
77 Console
.WriteLine ("WebServer Ready!");