dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.85k stars 667 forks source link

ASP.NET Core client side Blazor applications can't be run in VSCode #3024

Open NTaylorMullen opened 5 years ago

NTaylorMullen commented 5 years ago

This was originally reported over in https://github.com/aspnet/AspNetCore/issues/9451 and it seems that the dialog to add build assets to the project can't detect Blazor client side applications because they're not true runnable applications on their own.

To fix this there's two steps:

  1. Make runnable project detection understand Blazor client side applications
  2. Update the run .net core console app to utilize dotnet run --no-build instead of dotnet *.dll. The distinction about using dotnet run enables the Blazor project to hijack the run process and properly boot a runnable application.

/cc @danroth27

gregg-miskelly commented 5 years ago

I don't think this plan will work -- launch.json configurations need to be for both running and debugging and, at least the .NET Debugger, will not be able to work if you launch the problem using dotnet run.

NTaylorMullen commented 5 years ago

Hmmm interesting. Why is it that dotnet run can't be debugged?

gregg-miskelly commented 5 years ago

dotnet run will launch the target in a child process. The .NET Debugging APIs have no support for child process debugging.

gregg-miskelly commented 5 years ago

Actually, thinking more - this is a much bigger problem than just tweaking launch.json a little.

For a pure client app - what you want F5 to do is start the Blazor web server not under a debugger, and then after it is ready, launch Chrome (or whatever supported web browser), and connect the Chrome debug adapter to it.

For a 'Blazor (ASP.NET Core hosted)' app it might make sense to debug both at the same time.

NTaylorMullen commented 5 years ago

I see I see, ya good point. @SteveSandersonMS / @danroth27 is Blazor debugging in the browser in a viable/workable state?

danroth27 commented 5 years ago

@NTaylorMullen Debugging Blazor in the browser is still pretty rough. Eventually though we do want to have an integrated experience where you can just F5 and have VS launch the browser with remote debugging enabled and then correctly attach.

danroth27 commented 5 years ago

For comparison, in VS we also don't support F5 for client-side Blazor apps. You have to Ctrl-F5, and it's been that way for over a year now.

gregg-miskelly commented 5 years ago

Here are my suggestions:

  1. Don't do anything right now in terms of launch.json generation. We can leave this bug open to consider doing something someday for it.
  2. Update the documentation to point point at running the dotnet watch task.