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.
Original post (for Windows 10 and earlier):
- Right-click project and select properties.
- Click the Debug tab.
- Create a new profile.
- Set Launch set to Executable.
- Set Executable to the full path to the Windows Terminal executable (maybe C:\Users\<username>\AppData\Local\Microsoft\WindowsApps\wt.exe).
- Set Application arguments to dotnet.exe run -p <full path to .csproj file>.
- Set Working directory to the full path to the folder that contains the .csproj file.
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.
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.
Here is an example of the result:
To debug, press Ctrl+Alt+P or click Debug and then Attach to Process, and then select our .NET process and click Attach.
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.
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: