|
3 | 3 |
|
4 | 4 | using System;
|
5 | 5 | using System.Collections.Generic;
|
| 6 | +using System.Diagnostics; |
| 7 | +using System.IO; |
6 | 8 | using System.Linq;
|
7 | 9 | using System.Net;
|
8 | 10 | using System.Net.Http;
|
@@ -89,19 +91,26 @@ private static async Task DebugHome(HttpContext context)
|
89 | 91 | }
|
90 | 92 | catch (Exception ex)
|
91 | 93 | {
|
92 |
| - |
93 | 94 | await context.Response.WriteAsync($@"
|
94 |
| - <h1>Unable to find debuggable browser tab</h1> |
95 |
| - <p> |
96 |
| - Could not get a list of browser tabs from <code>{debuggerTabsListUrl}</code>. |
97 |
| - Ensure Chrome is running with debugging enabled. |
98 |
| - </p> |
99 |
| - <h2>Resolution</h2> |
| 95 | +<h1>Unable to find debuggable browser tab</h1> |
| 96 | +<p> |
| 97 | + Could not get a list of browser tabs from <code>{debuggerTabsListUrl}</code>. |
| 98 | + Ensure your browser is running with debugging enabled. |
| 99 | +</p> |
| 100 | +<h2>Resolution</h2> |
| 101 | +<p> |
| 102 | + <h4>If you are using Google Chrome for your development, follow these instructions:</h4> |
100 | 103 | {GetLaunchChromeInstructions(appRootUrl)}
|
101 |
| - <p>... then use that new tab for debugging.</p> |
102 |
| - <h2>Underlying exception:</h2> |
103 |
| - <pre>{ex}</pre> |
104 |
| -"); |
| 104 | +</p> |
| 105 | +<p> |
| 106 | + <h4>If you are using Microsoft Edge (Chromium) for your development, follow these instructions:</h4> |
| 107 | + {GetLaunchEdgeInstructions(appRootUrl)} |
| 108 | +</p> |
| 109 | +<strong>This should launch a new browser window with debugging enabled..</p> |
| 110 | +<h2>Underlying exception:</h2> |
| 111 | +<pre>{ex}</pre> |
| 112 | + "); |
| 113 | + |
105 | 114 | return;
|
106 | 115 | }
|
107 | 116 |
|
@@ -144,20 +153,42 @@ There is more than one browser tab at <code>{targetTabUrl}</code>.
|
144 | 153 |
|
145 | 154 | private static string GetLaunchChromeInstructions(string appRootUrl)
|
146 | 155 | {
|
| 156 | + var profilePath = Path.Combine(Path.GetTempPath(), "blazor-edge-debug"); |
| 157 | + |
147 | 158 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
148 | 159 | {
|
149 |
| - return $@"<p>Close all Chrome instances, then press Win+R and enter the following:</p> |
150 |
| - <p><strong><code>""%programfiles(x86)%\Google\Chrome\Application\chrome.exe"" --remote-debugging-port=9222 {appRootUrl}</code></strong></p>"; |
| 160 | + return $@"<p>Press Win+R and enter the following:</p> |
| 161 | + <p><strong><code>chrome --remote-debugging-port=9222 --user-data-dir=""{profilePath}"" {appRootUrl}</code></strong></p>"; |
151 | 162 | }
|
152 | 163 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
153 | 164 | {
|
154 |
| - return $@"<p>Close all Chrome instances, then in a terminal window execute the following:</p> |
155 |
| - <p><strong><code>google-chrome --remote-debugging-port=9222 {appRootUrl}</code></strong></p>"; |
| 165 | + return $@"<p>In a terminal window execute the following:</p> |
| 166 | + <p><strong><code>google-chrome --remote-debugging-port=9222 --user-data-dir={profilePath} {appRootUrl}</code></strong></p>"; |
| 167 | + } |
| 168 | + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
| 169 | + { |
| 170 | + return $@"<p>Execute the following:</p> |
| 171 | + <p><strong><code>open /Applications/Google\ Chrome.app --args --remote-debugging-port=9222 --user-data-dir={profilePath} {appRootUrl}</code></strong></p>"; |
| 172 | + } |
| 173 | + else |
| 174 | + { |
| 175 | + throw new InvalidOperationException("Unknown OS platform"); |
| 176 | + } |
| 177 | + } |
| 178 | + |
| 179 | + private static string GetLaunchEdgeInstructions(string appRootUrl) |
| 180 | + { |
| 181 | + var profilePath = Path.Combine(Path.GetTempPath(), "blazor-chrome-debug"); |
| 182 | + |
| 183 | + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| 184 | + { |
| 185 | + return $@"<p>Press Win+R and enter the following:</p> |
| 186 | + <p><strong><code>msedge --remote-debugging-port=9222 --user-data-dir=""{profilePath}"" {appRootUrl}</code></strong></p>"; |
156 | 187 | }
|
157 | 188 | else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
158 | 189 | {
|
159 |
| - return $@"<p>Close all Chrome instances, then in a terminal window execute the following:</p> |
160 |
| - <p><strong><code>open /Applications/Google\ Chrome.app --args --remote-debugging-port=9222 {appRootUrl}</code></strong></p>"; |
| 190 | + return $@"<p>In a terminal window execute the following:</p> |
| 191 | + <p><strong><code>open /Applications/Microsoft\ Edge\ Dev.app --args --remote-debugging-port=9222 --user-data-dir={profilePath} {appRootUrl}</code></strong></p>"; |
161 | 192 | }
|
162 | 193 | else
|
163 | 194 | {
|
|
0 commit comments