如何使用launch.json定位平台

问题描述 投票:0回答:1

omnisharp ReadMe说:

特定于操作系统的配置

如果每个操作系统需要更改特定命令,则可以使用以下字段:'windows','osx'或'linux'。您可以替换特定操作系统的上述任何字段。

这是我的launch.json文件:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/TestConsole/bin/Debug/netcoreapp2.1/TestConsole.dll",
            "args": [
                "c:\\git\\core\\XunitTestLib\\Steps\\",
                // "~/../../XunitTestLib/Steps"
            ],
            "cwd": "${workspaceFolder}/TestConsole",
            "console": "internalConsole",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        },
    ]
}

在调试时,我想在Windows上构建,以取消注释的"args"条目开始,但在mac os上,我希望它从注释掉的行开始。

我假设我会复制配置,一次用于Windows和mac,每个,但这句话令人困惑:

您可以替换特定操作系统的上述任何字段。

似乎在说我可以用"args"取代"osx",但这显然不起作用。

如何为目标平台创建配置?

windows macos visual-studio-code .net-core launch
1个回答
0
投票

事实证明,针对多个平台比我预期的要容易得多,并且explained here关于tasks.json文件(但launch.json的工作原理相同)。

我为osxwindows调整的launch.json文件看起来像这样:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": ".NET Core Launch (console)",
            "type": "coreclr",
            "request": "launch",
            "preLaunchTask": "build",
            "program": "${workspaceFolder}/TestConsole/bin/Debug/netcoreapp2.1/TestConsole.dll",
            "windows": {
                "args": [
                    "c:\\git\\core\\XunitTestLib\\Steps\\"
                ]
            },
            "osx": {
                "args": [
                    "~/../../XunitTestLib/Steps"
                ]
            },
            "cwd": "${workspaceFolder}/TestConsole",
            "console": "internalConsole",
            "stopAtEntry": false,
            "internalConsoleOptions": "openOnSessionStart"
        },
        {
            "name": ".NET Core Attach",
            "type": "coreclr",
            "request": "attach",
            "processId": "${command:pickProcess}"
        },
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.