防止控制台应用程序 (.NET Core) 在 VS2019 中打印 "exited with code 0."

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

当我在 Visual Studio Community 2019(版本 16.3.1)中使用 Ctrl+F5(无需调试启动)启动控制台应用程序(.NET Core)时,控制台中附加了以下消息 window 最后:

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!");
        }
    }
}

有什么方法可以防止Visual Studio 2019 打印这条消息吗?我通过更改选项尝试了 preventing a similar message from appearing in the Output Window 中的解决方案:工具 > 选项 > 调试 > 输出 Window > 进程退出消息 = 关闭,但它在控制台 Window 中没有效果。

注意:此消息未在 Visual Studio 2017 年显示。仅在 Visual Studio 2019 年显示,并且仅在 .NET Core 应用程序上显示。

您可以通过选中 Tools > Options > Debugging > General > Automatically close the console when debugging stops 选项来禁用它:

如控制台本身所述(Visual Studio 2019 v16.3.2):

这将使控制台只打印 Press any key to continue... 开始而不调试 (CTRL + F5) 而不是退出代码(仍然保持控制台打开):