Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add launch profile option to use integrated terminal #9353

Open
drewnoakes opened this issue Dec 18, 2023 · 3 comments
Open

Add launch profile option to use integrated terminal #9353

drewnoakes opened this issue Dec 18, 2023 · 3 comments
Labels
Feature Request Request for a new feature, or new scenario to be handled. Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. Triage-Approved Reviewed and prioritized
Milestone

Comments

@drewnoakes
Copy link
Member

Today, when launching a console app, a new terminal window is opened.

VS has an integrated terminal that appears within a tool window.

The debugging infrastructure supports a launch option to do this. We just need to plumb it through from the UI, to launchSettings.json, to the launch invocation.

We might also want to add an option (Tools|Options) that controls the default value for when the property is not present in the launchSettings.json.

For an example of integrating this feature, see https://devdiv.visualstudio.com/DevDiv/_git/WebTools/pullrequest/425844?_a=files&path=/src/ProjectSystem/Web/WebServer/SelfHostWebServer.cs (MS internal).

@drewnoakes drewnoakes added the Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. label Dec 18, 2023
@tmeschter tmeschter added the Feature Request Request for a new feature, or new scenario to be handled. label Jan 11, 2024
@tmeschter tmeschter modified the milestones: Backlog, 17.10 Jan 11, 2024
@drewnoakes drewnoakes added the Triage-Approved Reviewed and prioritized label Jan 18, 2024
@drewnoakes
Copy link
Member Author

Sharing some findings.

Enabling this feature is straightforward:

diff --git a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Debug/ProjectLaunchTargetsProvider.cs b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Debug/ProjectLaunchTargetsProvider.cs
index 1c095a8fb..7cada1fa0 100644
--- a/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Debug/ProjectLaunchTargetsProvider.cs
+++ b/src/Microsoft.VisualStudio.ProjectSystem.Managed.VS/ProjectSystem/VS/Debug/ProjectLaunchTargetsProvider.cs
@@ -360,7 +360,8 @@ private async Task<bool> IsIntegratedConsoleEnabledAsync()
             {
                 if (await IsIntegratedConsoleEnabledAsync())
                 {
-                    settings.LaunchOptions |= DebugLaunchOptions.IntegratedConsole;
+                    const int DBGLAUNCH_UseIntegratedTerminalService = 0x20000000;
+                    settings.LaunchOptions |= DebugLaunchOptions.IntegratedConsole | (DebugLaunchOptions)DBGLAUNCH_UseIntegratedTerminalService;
                 }

                 useCmdShell = UseCmdShellForConsoleLaunch(resolvedProfile, settings.LaunchOptions);

The result is this:

image

Despite it being easy to turn this feature on, there are a few open questions:

  • How do we allow users to configure this? Currently the ⚙️ icon in the terminal window launches the Web Tools settings, where an option for this lives. The option should be centralised in the Debugging area. The screenshot shows a console app.
  • The terminal window pane is visible during debugging (just like Call Stack, Locals, etc) and closes when debugging stops. Having the program's output disappear when the process exits doesn't seem great. Consider if the app crashes — there's no way to see logged errors.
  • If you Ctrl+F5, the terminal window is visible and remains in the UI (avoiding the previous issue). However if you then F5, a different instance of the terminal is displayed during debugging, then the non-debug terminal is displayed again when the debugging session ends, which is confusing.

Overall, I like the idea of adding this but we will need to work through the above issues with other teams before we can ship this.

@drewnoakes
Copy link
Member Author

CPS PR to add DebugLaunchOptions member: https://dev.azure.com/devdiv/DevDiv/_git/CPS/pullrequest/524465

@drewnoakes
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for a new feature, or new scenario to be handled. Feature-Debugging Launching an application via F5, setting debug properties and launch profiles. Triage-Approved Reviewed and prioritized
Projects
None yet
Development

No branches or pull requests

2 participants