Prevent a Console App (.NET Core) from printing "exited with code 0." in VS2019

Viewed 10411

When I start a Console App (.NET Core) with Ctrl+F5 (Start Without Debugging) in Visual Studio Community 2019 (Version 16.3.1), the following message is appended in the Console window at the end:

C:\HelloWorld\bin\Debug\netcoreapp3.0\HelloWorld.exe (process 1672) exited with code 0.

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}

Console output

Is there any way to prevent Visual Studio 2019 from printing this message? I tried the solution from preventing a similar message from appearing in the Output Window, by changing the option: Tools > Options > Debugging > Output Window > Process Exit Messages = Off, but it has no effect in the Console Window.

Visual Studio Options

Note: this message is not shown in Visual Studio 2017. It is only shown in Visual Studio 2019, and only on .NET Core apps.

1 Answers

You can disable it by checking the Tools > Options > Debugging > General > Automatically close the console when debugging stops option:

Visual Studio 2019 Options

As stated by the console itself (Visual Studio 2019 v16.3.2):

Console App

That will make the console just print Press any key to continue... by starting without debugging (CTRL + F5) and not the exit code (still leaves the console open):

No exit code

Related