在 Visual Studio 2017 年调试 .Net Core 控制台应用程序

Debug .Net Core Console App out of Visual Studio 2017

我想 运行 并调试 .Net Core (2.2) 控制台应用程序(不是 ASP.Net Core!)。 因此,我创建了一个非常简单的应用程序:

public static class Program
{
    public static void Main(string[] args)
    {
        WriteLine("**Environment**");
        WriteLine($"Platform: .NET Core");
        WriteLine($"OS: {RuntimeInformation.OSDescription}");
        WriteLine();
        ReadLine();
    }

    private static (string, bool) ParseArgs(string[] args)
    {
        var buffer = new StringBuilder();
        var withColor = false;
        foreach (var s in args)
        {
            if (s == "--with-color")
            {
                withColor = true;
                continue;
            }
            buffer.Append(" ");
            buffer.Append(s);
        }

        return (buffer.ToString(), withColor);
    }
}

添加了一个 Docker 文件。

添加了 Microsoft.VisualStudio.Azure.Containers.Tools.Targets NuGet 包。

最终将 launchSettings.json 更改为:

{
  "profiles": {
    "dotnetapp": {
      "commandName": "Project"
    },
    "Docker": {
      "commandName": "Docker"
    }
  }
}

所以一切看起来都像在默认 ASP.Net 核心 WebApp 中一样 docker 支持。

但是在 "run" 我只得到一个错误 "The profile 'Docker' can not be executed with this application"。

我不明白,有什么区别?我怎样才能 运行 像 .Net Core ASP 应用程序一样简单的 .Net Core 应用程序?

似乎没有答案,但它似乎适用于 Visual Studio 2019 年的 Steffen(和我自己)。也许 Visual Studio 2017 工具中存在错误...