dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.83k stars 654 forks source link

Support internal/external terminal for web projects #7165

Open davidfowl opened 1 month ago

davidfowl commented 1 month ago

When you launch a console or .NET project in Visual Studio with F5 there's an external console window that pops up with the output (this can be configured to use the in IDE terminal window as well).

VS

https://github.com/dotnet/vscode-csharp/assets/95136/3a32dbbf-4f8a-41b1-bd8c-6c0550e5ecf0

In VS code the focus is on the debug output and the console output and debug spew is interleaved making it extremely hard to look at the output:

VS Code

https://github.com/dotnet/vscode-csharp/assets/95136/7c0fdfbe-c2a5-460a-a9b7-2beabcd8d502

Instead, we should show the console output from launches in a terminal window (similar to how to build is done)

WardenGnaw commented 1 month ago

For Console Projects, the default will be the Terminal output tab or if a user has configured a csharp.debug.console setting, it will use that instead.

For ASP.NET projects, due to how VS Code detects when to auto launch the web browser, it is currently required to print the output into the Debug Console.

See https://code.visualstudio.com/docs/editor/debugging#_automatically-open-a-uri-when-debugging-a-server-program

One thought is if we can also just log the ASP.NET URI into the debug console for the serverReadyAction but default all stdout/stderr to the Terminal Window and use that as the default

cc: @gregg-miskelly

davidfowl commented 1 month ago

I think we should aim to make the experience similar to how the console apps work and use a terminal for output. If using the terminal and launching via the browser is impossible then we need to ask vscode for a new feature.

The console is in important for logs and the debug window is fully of other debug messages that make it hard to visually parse the output.

Anecdotally we taught a C# beginner course and used dotnet run because the debug window is visually noisy.

gregg-miskelly commented 1 month ago

I think it would be possible to support using the internal/external terminal, though not particularly cheaply. We still need to fire an event to VS Code to let them know that the web browser is ready, which means that the debugger needs to redirect stdout to itself, but what we could do is:

davidfowl commented 4 weeks ago

Seems like we have this today when you run without the debugger for console apps but not web projects?

https://github.com/dotnet/vscode-csharp/assets/95136/16514cc2-38c9-4bed-91f1-75cd218fa107

gregg-miskelly commented 3 weeks ago

Correct -- for non-web projects, we support internal and external terminals (and default to internal terminal for start without debugging).

davidfowl commented 3 weeks ago

Why the difference?

WardenGnaw commented 3 weeks ago

The difference is due to launching the web browser and how VS Code detects that the web page is ready. For Console projects, we don't have to launch the browser.

See https://github.com/dotnet/vscode-csharp/issues/7165#issuecomment-2133919387

davidfowl commented 3 weeks ago

For ASP.NET projects, due to how VS Code detects when to auto launch the web browser, it is currently required to print the output into the Debug Console.

Got it.