New option in Visual Studio 2019 keeps console window open after debugging

4 Comments

For as long as I've been writing console applications, I've at the end of Main I've always had a piece of code to require user input before exiting when in debug mode, in order to review any output before the window closes. Not an onerous task, but one I immediately do as soon as creating a new application.

New features?

Today I created a new .NET Core console application in Visual Studio 2019 preview and added by code without a second thought.

When I ran the application I was in for two surprises - the first was the icon had changed, to a fetching purple. The second was, after the program had ran and displayed my usual "(Press any key to exit.)" message, the console stayed open - with another message to press a key to exit.

Visual Studio now automatically keeps console windows opening after the program ends
Visual Studio now automatically keeps console windows opening after the program ends

A small change, but a welcome one! And, just in case it's not to everyone's liking, there's even an option to disable the behaviour if you don't like it.

A new option for allow the console to automatically close has been added
A new option for allow the console to automatically close has been added

Always a catch

Unfortunately, this new option doesn't seem to work for old school console applications using the full .NET Framework, so I'll continue adding my boilerplate blocks to any new .NET Framework console applications I create.