Initial working end-to-end
This commit is contained in:
parent
691910c67d
commit
302d79a347
|
|
@ -306,9 +306,9 @@
|
|||
<Uri>https://github.com/dotnet/runtime</Uri>
|
||||
<Sha>1dfd9438149f74ae11918a7b0709b8d58c61443f</Sha>
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="5.0.0-rc.1.20414.5">
|
||||
<Dependency Name="Microsoft.NETCore.BrowserDebugHost.Transport" Version="5.0.0-rc.1.20428.3">
|
||||
<Uri>https://github.com/dotnet/runtime</Uri>
|
||||
<Sha>6cc7cffaff2e0413ee84d9a7736f9ae1aa9a3f12</Sha>
|
||||
<Sha>1dfd9438149f74ae11918a7b0709b8d58c61443f</Sha>
|
||||
</Dependency>
|
||||
</ProductDependencies>
|
||||
<ToolsetDependencies>
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@
|
|||
<MicrosoftNETCoreAppInternalPackageVersion>5.0.0-rc.1.20428.3</MicrosoftNETCoreAppInternalPackageVersion>
|
||||
<MicrosoftNETCoreAppRefPackageVersion>5.0.0-rc.1.20428.3</MicrosoftNETCoreAppRefPackageVersion>
|
||||
<MicrosoftNETCoreAppRuntimewinx64PackageVersion>5.0.0-rc.1.20428.3</MicrosoftNETCoreAppRuntimewinx64PackageVersion>
|
||||
<MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>5.0.0-rc.1.20428.3</MicrosoftNETCoreBrowserDebugHostTransportPackageVersion>
|
||||
<MicrosoftWin32RegistryPackageVersion>5.0.0-rc.1.20428.3</MicrosoftWin32RegistryPackageVersion>
|
||||
<MicrosoftWin32SystemEventsPackageVersion>5.0.0-rc.1.20428.3</MicrosoftWin32SystemEventsPackageVersion>
|
||||
<MicrosoftExtensionsCachingAbstractionsPackageVersion>5.0.0-rc.1.20428.3</MicrosoftExtensionsCachingAbstractionsPackageVersion>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ using System.Reflection;
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.CommandLineUtils;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
|
|
@ -24,20 +26,20 @@ namespace Microsoft.AspNetCore.Builder
|
|||
private static readonly Regex NowListeningRegex = new Regex(@"^\s*Now listening on: (?<url>.*)$", RegexOptions.None, TimeSpan.FromSeconds(10));
|
||||
private static readonly Regex ApplicationStartedRegex = new Regex(@"^\s*Application started\. Press Ctrl\+C to shut down\.$", RegexOptions.None, TimeSpan.FromSeconds(10));
|
||||
|
||||
public static Task<string> EnsureLaunchedAndGetUrl(IServiceProvider serviceProvider)
|
||||
public static Task<string> EnsureLaunchedAndGetUrl(IServiceProvider serviceProvider, string devToolsHost)
|
||||
{
|
||||
lock (LaunchLock)
|
||||
{
|
||||
if (LaunchedDebugProxyUrl == null)
|
||||
{
|
||||
LaunchedDebugProxyUrl = LaunchAndGetUrl(serviceProvider);
|
||||
LaunchedDebugProxyUrl = LaunchAndGetUrl(serviceProvider, devToolsHost);
|
||||
}
|
||||
|
||||
return LaunchedDebugProxyUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<string> LaunchAndGetUrl(IServiceProvider serviceProvider)
|
||||
private static async Task<string> LaunchAndGetUrl(IServiceProvider serviceProvider, string devToolsHost)
|
||||
{
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
|
||||
|
|
@ -45,10 +47,11 @@ namespace Microsoft.AspNetCore.Builder
|
|||
var executablePath = LocateDebugProxyExecutable(environment);
|
||||
var muxerPath = DotNetMuxer.MuxerPathOrDefault();
|
||||
var ownerPid = Process.GetCurrentProcess().Id;
|
||||
|
||||
var processStartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = muxerPath,
|
||||
Arguments = $"exec \"{executablePath}\"",
|
||||
Arguments = $"exec \"{executablePath}\" --owner-pid {ownerPid} --DevToolsUrl {devToolsHost}",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
|
||||
<Reference Include="Microsoft.NETCore.BrowserDebugHost.Transport" GeneratePathProperty="true"/>
|
||||
<!-- Dependencies needed by DebugProxy. -->
|
||||
<Reference Include= "Newtonsoft.Json" />
|
||||
<Reference Include="Microsoft.NETCore.BrowserDebugHost.Transport" GeneratePathProperty="true" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
@ -32,12 +30,7 @@
|
|||
<Target Name="IncludeDebugProxyBinariesAsContent" BeforeTargets="AssignTargetPaths">
|
||||
<ItemGroup>
|
||||
<DebugProxyBinaries Include="$(PkgMicrosoft_NETCore_BrowserDebugHost_Transport)\tools\$(DefaultNetCoreTargetFramework)\**" />
|
||||
<Content
|
||||
Include="@(DebugProxyBinaries)"
|
||||
Pack="true"
|
||||
PackagePath="tools\BlazorDebugProxy\%(RecursiveDir)%(FileName)%(Extension)"
|
||||
Link="BlazorDebugProxy\%(RecursiveDir)%(FileName)%(Extension)"
|
||||
CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="@(DebugProxyBinaries)" Pack="true" PackagePath="tools\BlazorDebugProxy\%(RecursiveDir)%(FileName)%(Extension)" Link="BlazorDebugProxy\%(RecursiveDir)%(FileName)%(Extension)" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,12 +23,13 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
IgnoreNullValues = true
|
||||
};
|
||||
|
||||
private readonly string BrowserHost = "http://localhost:9222";
|
||||
private string _browserHost;
|
||||
private string _debugProxyUrl;
|
||||
|
||||
public TargetPickerUi(string debugProxyUrl)
|
||||
public TargetPickerUi(string debugProxyUrl, string devToolsHost)
|
||||
{
|
||||
_debugProxyUrl = debugProxyUrl;
|
||||
_browserHost = devToolsHost;
|
||||
}
|
||||
|
||||
public async Task Display(HttpContext context)
|
||||
|
|
@ -38,7 +39,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
var request = context.Request;
|
||||
var targetApplicationUrl = request.Query["url"];
|
||||
|
||||
var debuggerTabsListUrl = $"{BrowserHost}/json";
|
||||
var debuggerTabsListUrl = $"{_browserHost}/json";
|
||||
IEnumerable<BrowserTab> availableTabs;
|
||||
|
||||
try
|
||||
|
|
@ -137,7 +138,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
{
|
||||
var underlyingV8Endpoint = new Uri(tabToDebug.WebSocketDebuggerUrl);
|
||||
var proxyEndpoint = new Uri(_debugProxyUrl);
|
||||
var devToolsUrlAbsolute = new Uri(BrowserHost + tabToDebug.DevtoolsFrontendUrl);
|
||||
var devToolsUrlAbsolute = new Uri(_browserHost + tabToDebug.DevtoolsFrontendUrl);
|
||||
var devToolsUrlWithProxy = $"{devToolsUrlAbsolute.Scheme}://{devToolsUrlAbsolute.Authority}{devToolsUrlAbsolute.AbsolutePath}?{underlyingV8Endpoint.Scheme}={proxyEndpoint.Authority}{underlyingV8Endpoint.PathAndQuery}";
|
||||
return devToolsUrlWithProxy;
|
||||
}
|
||||
|
|
@ -145,7 +146,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
private string GetLaunchChromeInstructions(string targetApplicationUrl)
|
||||
{
|
||||
var profilePath = Path.Combine(Path.GetTempPath(), "blazor-chrome-debug");
|
||||
var debuggerPort = new Uri(BrowserHost).Port;
|
||||
var debuggerPort = new Uri(_browserHost).Port;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
|
@ -171,7 +172,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
private string GetLaunchEdgeInstructions(string targetApplicationUrl)
|
||||
{
|
||||
var profilePath = Path.Combine(Path.GetTempPath(), "blazor-edge-debug");
|
||||
var debuggerPort = new Uri(BrowserHost).Port;
|
||||
var debuggerPort = new Uri(_browserHost).Port;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
|
|
@ -210,7 +211,7 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Server
|
|||
private async Task<IEnumerable<BrowserTab>> GetOpenedBrowserTabs()
|
||||
{
|
||||
using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
|
||||
var jsonResponse = await httpClient.GetStringAsync($"{BrowserHost}/json");
|
||||
var jsonResponse = await httpClient.GetStringAsync($"{_browserHost}/json");
|
||||
return JsonSerializer.Deserialize<BrowserTab[]>(jsonResponse, JsonOptions);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Server;
|
||||
|
||||
namespace Microsoft.AspNetCore.Builder
|
||||
|
|
@ -21,7 +23,17 @@ namespace Microsoft.AspNetCore.Builder
|
|||
{
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var debugProxyBaseUrl = await DebugProxyLauncher.EnsureLaunchedAndGetUrl(context.RequestServices);
|
||||
var queryParams = HttpUtility.ParseQueryString(context.Request.QueryString.Value);
|
||||
var browserParam = queryParams.Get("browser");
|
||||
Uri browserUrl = null;
|
||||
var devToolsHost = "http://localhost:9222";
|
||||
if (browserParam != null)
|
||||
{
|
||||
browserUrl = new Uri(browserParam);
|
||||
devToolsHost = $"http://{browserUrl.Host}:{browserUrl.Port}";
|
||||
}
|
||||
|
||||
var debugProxyBaseUrl = await DebugProxyLauncher.EnsureLaunchedAndGetUrl(context.RequestServices, devToolsHost);
|
||||
var requestPath = context.Request.Path.ToString();
|
||||
if (requestPath == string.Empty)
|
||||
{
|
||||
|
|
@ -31,11 +43,11 @@ namespace Microsoft.AspNetCore.Builder
|
|||
switch (requestPath)
|
||||
{
|
||||
case "/":
|
||||
var targetPickerUi = new TargetPickerUi(debugProxyBaseUrl);
|
||||
var targetPickerUi = new TargetPickerUi(debugProxyBaseUrl, devToolsHost);
|
||||
await targetPickerUi.Display(context);
|
||||
break;
|
||||
case "/ws-proxy":
|
||||
context.Response.Redirect($"{debugProxyBaseUrl}{requestPath}{context.Request.QueryString}");
|
||||
context.Response.Redirect($"{debugProxyBaseUrl}{browserUrl.PathAndQuery}");
|
||||
break;
|
||||
default:
|
||||
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||
|
|
|
|||
Loading…
Reference in New Issue