如何将 VS Code launch.json 转换为 .Net Core Web 应用程序的 Visual Studio launchSettings.json

jon*_*562 6 visual-studio docker .net-core visual-studio-code

我需要将 VSCode 中的 launch.json 文件转换为 Windows 上 Visual Studio 中的 launchSettings.json 文件,以便可以使用 Docker 进行调试。下面是我在 VSCode 中运行的 launch.json 文件。

{
"version": "0.2.0",
"configurations": [
    {
        "name":".NET Core Docker Launch (web)",
        "type": "coreclr",
        "request": "launch",
        "preLaunchTask": "composeForDebug",
        "cwd": "/app",
        "program": "/app/test.dll",
        "sourceFileMap": {
            "/app": "${workspaceRoot}"
        },

        "launchBrowser": {
            "enabled": true,
            "args": "${auto-detect-url}",
            "windows": {
                "command": "cmd.exe",
                "args": "/C start ${auto-detect-url}"
            },
            "osx": {
                "command": "open"
            }
        },

        "pipeTransport": {
            "pipeProgram": "/bin/bash",
            "pipeCwd": "${workspaceRoot}",
            "pipeArgs": [ "-c", "./dockerTask.sh startDebugging" ],
            "windows": {
                "pipeProgram": "${env.windir}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
                "pipeCwd": "${workspaceRoot}",
                "pipeArgs": [ ".\\dockerTask.ps1", "-StartDebugging" ]
            }
        }
    }
]}
Run Code Online (Sandbox Code Playgroud)

下面是 Windows 端 Visual Studio 中的 launchSettings.json 文件。它与在 Visual Studio 中创建新的 .Net Core Web 应用程序时生成的 launchSettings.json 文件几乎相同。当我尝试使用 launchSettings.json 文件进行调试时,它允许我使用 Docker 进行调试,但我收到类似““PrepareForLaunch”任务意外失败”的错误。我认为这是由于我的 launchSettings.json 文件中缺少一些配置。

    {
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:52667/",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "api": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:52668"
    },
    "Docker": {
      "launchBrowser": true,
      "launchUrl": "http://localhost:{ServicePort}"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)