diff options
Diffstat (limited to 'sdks/wasm/BrowserDebugHost/Program.cs')
-rw-r--r-- | sdks/wasm/BrowserDebugHost/Program.cs | 101 |
1 files changed, 30 insertions, 71 deletions
diff --git a/sdks/wasm/BrowserDebugHost/Program.cs b/sdks/wasm/BrowserDebugHost/Program.cs index faaa4960c58..c5acedd5e16 100644 --- a/sdks/wasm/BrowserDebugHost/Program.cs +++ b/sdks/wasm/BrowserDebugHost/Program.cs @@ -1,81 +1,40 @@ -using System; +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; using System.IO; using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; -using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace WebAssembly.Net.Debugging +namespace Microsoft.WebAssembly.Diagnostics { - public class ProxyOptions { - public Uri DevToolsUrl { get; set; } = new Uri ("http://localhost:9222"); - } - - public class TestHarnessOptions : ProxyOptions { - public string ChromePath { get; set; } - public string AppPath { get; set; } - public string PagePath { get; set; } - public string NodeApp { get; set; } - } - - public class Program { - public static void Main(string[] args) - { - var host = new WebHostBuilder() - .UseSetting ("UseIISIntegration", false.ToString ()) - .UseKestrel () - .UseContentRoot (Directory.GetCurrentDirectory()) - .UseStartup<Startup> () - .ConfigureAppConfiguration ((hostingContext, config) => - { - config.AddCommandLine(args); - }) - .UseUrls ("http://localhost:9300") - .Build (); - - host.Run (); - } - } - - public class TestHarnessProxy { - static IWebHost host; - static Task hostTask; - static CancellationTokenSource cts = new CancellationTokenSource (); - static object proxyLock = new object (); - - public static readonly Uri Endpoint = new Uri ("http://localhost:9400"); - - public static Task Start (string chromePath, string appPath, string pagePath) - { - lock (proxyLock) { - if (host != null) - return hostTask; - - host = WebHost.CreateDefaultBuilder () - .UseSetting ("UseIISIntegration", false.ToString ()) - .ConfigureAppConfiguration ((hostingContext, config) => { - config.AddEnvironmentVariables (prefix: "WASM_TESTS_"); - }) - .ConfigureServices ((ctx, services) => { - services.Configure<TestHarnessOptions> (ctx.Configuration); - services.Configure<TestHarnessOptions> (options => { - options.ChromePath = options.ChromePath ?? chromePath; - options.AppPath = appPath; - options.PagePath = pagePath; - options.DevToolsUrl = new Uri ("http://localhost:0"); - }); - }) - .UseStartup<TestHarnessStartup> () - .UseUrls (Endpoint.ToString ()) - .Build(); - hostTask = host.StartAsync (cts.Token); - } - - Console.WriteLine ("WebServer Ready!"); - return hostTask; - } - } + public class ProxyOptions + { + public Uri DevToolsUrl { get; set; } = new Uri("http://localhost:9222"); + } + + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseSetting("UseIISIntegration", false.ToString()) + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseStartup<Startup>() + .ConfigureAppConfiguration((hostingContext, config) => + { + config.AddCommandLine(args); + }) + .UseUrls("http://localhost:9300") + .Build(); + + host.Run(); + } + } } |