Use Windows Terminal for Visual Studio Run and Debug

This blog post explains how get Visual Studio to use Windows Terminal to run and debug your projects rather than using the Windows console.

30.October.2021 Update: On a Windows 11 system, in Windows Terminal, click the down arrow to the right of the tabs, then Settings, then Startup, and then set “Default terminal application” to Windows Terminal.

Windows Terminal Settings

Original post (for Windows 10 and earlier):

  1. Right-click project and select properties.
  2. Click the Debug tab.
  3. Create a new profile.
  4. Set Launch set to Executable.
  5. Set Executable to the full path to the Windows Terminal executable (maybe C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\wt.exe).
  6. Set Application arguments to dotnet.exe run -p <full path to .csproj file>.
  7. Set Working directory to the full path to the folder that contains the .csproj file.
Visual Studio run/debug configuration

Update 25.Jan.2022: Value suggestions from a comment on this blog post from frederickjeanguerin:

1. Executable: $(userprofile)\AppData\Local\Microsoft\WindowsApps\wt.exe

2. Arguments: dotnet.exe run –Project $(projectpath)

3. Working Dir: $(projectdir)

End 25.Jan.2022 Update

In the Visual Studio toolbar, select the profile.

Visual Studio select a run/debug profile

Now when you run or debug, Visual Studio opens a command prompt to launch Windows Terminal. To make this command prompt disappear immediately afterwards, click Tools, then Options, then Debugging, and then select Automatically close the console when debugging stops.

Visual Studio options

Here is an example of the result:


Windows Terminal

To debug, press Ctrl+Alt+P or click Debug and then Attach to Process, and then select our .NET process and click Attach.

Attach Visual Studio debugger to process

If you need to debug something that occurs at initialization, you can use a different debugging profile temporarily that lets Visual Studio run the .NET process directly and attach the debugger automatically.

Update 4.September.2021:

On this other post, someone commented that this approach might not work if you download Windows Terminal through the Microsoft Store, as which does not use the wt.exe binary:

I responded that based on the following post on one of my other blogs:

I thought that the following might work:

explorer.exe shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App

4 thoughts on “Use Windows Terminal for Visual Studio Run and Debug

  1. I have successfully used your instructions to configure my VS to use the Windows Terminal, thanks, and I have made some changes as follow to make it independent of project location as a possible nice add-on:

    1. Executable: $(userprofile)\AppData\Local\Microsoft\WindowsApps\wt.exe

    2. Arguments: dotnet.exe run –Project $(projectpath)

    3. Working Dir: $(projectdir)

    Like

  2. What would be nice is if we could open the new window as its own instance, then any other windows as additional tabs in the same instance. I usually have two or three separate instances of Visual Studio so would be nice to be able to group them all in one terminal instead of each having their own.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: