I have downloaded the Samples to accompany the official Microsoft Blazor documentation
https://github.com/dotnet/blazor-samples
In VS Code then I open the folder
..blazor-samples-main6.0BlazorSample_WebAssembly
I let VS Code add the assets in the subfolder .vscode
launch.json
task.json
I have modified the launch.json to be
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch and Debug Standalone Blazor WebAssembly App",
"type": "blazorwasm",
"request": "launch",
"cwd": "${workspaceFolder}",
"url": "https://localhost:5001"
}
]}
and I have modified the launchSettings.json located in the Properties folder to be
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:57953",
"sslPort": 44307
}
},
"profiles": {
"blazorwasm": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"BlazorSample": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
I then run the Run > Start Debugging F5 but I get the error described in the title and captured in the screenshots
Has anyone ever encountered this problem in Visual Studio Code and knows how to fix it?
Have I missed anything or done anything wrong?
The same exact code with the blazorwasm configuration can be debugged successfully on Visual Studio 2022 but it fails as illustrated in Visual Studio Code and I do not understand why?
Some references I have used are below but I have not been able to understand the meaning of the error message below. I have tried to use Edge by switching the type in the blazorwasm but that causes Edge to crash right off the bat.
Unable to lauch browser "The URL’s protocol must be one of ws, wss or
ws+inix"
https://dev.to/sacantrell/vs-code-and-blazor-wasm-debug-with-hot-reload-5317
This is what I see on my PC
PS C:Users> dotnet --version
7.0.102
PS C:Users> dotnet --list-sdks
2.1.818 [C:Program Filesdotnetsdk]
3.1.426 [C:Program Filesdotnetsdk]
5.0.416 [C:Program Filesdotnetsdk]
6.0.302 [C:Program Filesdotnetsdk]
6.0.405 [C:Program Filesdotnetsdk]
7.0.102 [C:Program Filesdotnetsdk]
2
Answers
I ran into the same issues. The problem was that I had older dotnet SDKs installed. After uninstalling the older versions and restarting my computer everything worked fine. 🙂
blazorwasm-companion.launchDebugProxy v1.1.3 has been released today (2023-02-02) and resolves the issue.