【发布时间】:2021-10-03 08:03:37
【问题描述】:
我正在 Mac 上的 Visual Studio 8.9.10 中开发 netcore 3.1 控制台应用程序。 运行它时,应用程序会在 Visual Studio 本身的终端窗口中执行。
当我单击运行按钮时,我希望它在 mac 终端中运行。 我在项目选项中找不到正确的设置 - 没有像“在外部控制台上运行”之类的复选框。
提前谢谢你。
【问题讨论】:
我正在 Mac 上的 Visual Studio 8.9.10 中开发 netcore 3.1 控制台应用程序。 运行它时,应用程序会在 Visual Studio 本身的终端窗口中执行。
当我单击运行按钮时,我希望它在 mac 终端中运行。 我在项目选项中找不到正确的设置 - 没有像“在外部控制台上运行”之类的复选框。
提前谢谢你。
【问题讨论】:
我不肯定这是唯一的方法,但我的猜测是,将调试器附加到从终端启动的程序是目前唯一的方法。
类似这样的:https://stackoverflow.com/a/552788
为了方便和后代复制这里:
using System;
using System.Diagnostics;
using System.Threading;
namespace DebugApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Waiting for debugger to attach");
while (!Debugger.IsAttached)
{
Thread.Sleep(100);
}
Console.WriteLine("Debugger attached");
}
}
}
【讨论】: