47

How can I set the new Windows Terminal application to be used as debugging console in Visual Studio 2019? By default it launches cmd.exe when I debug.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Luka
  • 4,075
  • 3
  • 35
  • 61

6 Answers6

11

After the release of windows terminal 1.12 in combination with Windows 11 (or Windows Insider Program Dev Channel) it is now possible to set default terminal and point to Windows Terminal. After doing that the Visual Studio debugging console gets hosted in windows terminal when debugging console applications in visual studio (tested in vs2022)!

enter image description here

olabacker
  • 1,232
  • 1
  • 16
  • 27
  • 3
    Somehow I had this working in vs2019, but in vs2022 it doesn't work for me... – David Perfors Nov 11 '21 at 08:31
  • 2
    @DavidPerfors How did you do it? – carloswm85 Dec 27 '21 at 14:34
  • I didn’t do anything special, what I found out though is that simple console applications do open in Windows Terminal. Also in 2022. – David Perfors Dec 28 '21 at 16:21
  • Just set the default terminal in windows to windows terminal – olabacker Dec 28 '21 at 17:17
  • 2
    Unfortunately, this results in the terminal window not being re-used between runs. Back to cmd.exe until this is fixed. – David Bond Jan 14 '22 at 11:26
  • Can we leverage this to get ANSI colouring working for Visual Studio debug console output? – sleep Jul 26 '22 at 06:14
  • This works fine for Console apps, but for Webapps it doesn't seem to work. All my console apps nicely go inside 1 Terminal window with each their own tab, but the WebApi keeps opening a new separate window "Microsoft Visual Studio Debug Console" – Rik De Peuter Sep 01 '22 at 08:25
  • Note that the "Default terminal application" setting is not respected, if the console is created from a process with Administrator privileges. The old conhost is started in such a case. So if you start Visual Studio as administrator, you will NOT get the new Windows terminal. This is a broader problem which is not related just to VS. The Terminal developers are aware of it: https://github.com/microsoft/terminal/issues/10276 – Peter Macej Jul 05 '23 at 13:07
8

On Windows 10

To add to @Bravo's answer, I also tried searching the Windows registry for variants of "cmd", "cmd.exe" and so on in areas of the registry dedicated to Visual Studio, and couldn't seem to find anything.

A search of *.config, *.xml, *.json in Visual Studio related directories didn't seem to yield anything useful either.

For now, I've requested this feature in the Developer Community. If it makes sense to you, you might consider voting on that feature.

On Windows 11

See olabacker's answer, and perhaps follow the Developer Community discussion referenced above for more information.

Kit
  • 20,354
  • 4
  • 60
  • 103
3

Not really an answer, but I'd like to address a common misconception. Visual Studio doesn't launch cmd.exe, it just launches your application. Very much like cmd.exe itself, your application is a console application that runs inside a terminal, and for that Windows runs a terminal emulator that shows a GUI window that renders the text and passes your input back to the application.

On Windows, this terminal has been traditionally handled by Windows Console Host, or conhost.exe. Until Windows 11* you weren't allowed to change the default terminal emulator. They did change the backend architecture of the console API in Windows 10 (See for example this blogpost) to make it possible to run your own terminal emulator, which is what Windows Terminal implements.

My main point, to people referring to cmd.exe, what you really mean is conhost.exe.

* UPDATE 2023: It is now possible to configure a different default terminal in Windows 10 as well.

oisyn
  • 1,306
  • 5
  • 14
1

Currently, it is not supported yet, see the github issue Change Windows OS to support default terminal [defterm] · Issue #492 · microsoft/terminal

But maybe you can try below, locate the executable file of Windows Terminal, namely wt.exe or wtd.exe and record the path, then find in configs of VS to use path instead of cmd.exe.

Wish it be helpful for you!

Bravo Yeung
  • 8,654
  • 5
  • 38
  • 45
1

This is now possible with latest Windows Terminal in both Windows 10 and Windows 11. You just need to set the Windows Terminal as default terminal application:

Windows Terminal > Settings > Startup > Default terminal application: Windows Terminal enter image description here

ctyar
  • 931
  • 2
  • 10
  • 22
0

Also you can run windows terminal, start your console app in it, attach VS's debugger to your console app on windows terminal.

Useful links:

Debugging console

Attach to running processes with the Visual Studio debugger

Vadym
  • 63
  • 7