如何在VSCode调试器中禁用“仅我的代码”设置?

Rev*_*t64 12 visual-studio-code vscode-debugger

在调试器(C#.NET Core)中启动我的项目时,它表示正在调试“仅我的代码”。

我也想调试库,并且在VSCode的任何地方都看不到禁用此设置的设置。

可以禁用吗?

war*_*ens 40

VSCode 1.60 抱怨"request": "test"其他人建议的方法。

但我确实必须在现有配置下面添加一个新部分"justMyCode": false才能开始工作。

这对我有用:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": [
                "blah",
                "whatever"
            ]
        },
        {
            "name": "Python: Debug Unit Tests",
            "type": "python",
            "request": "launch",
            "purpose": ["debug-test"],
            "console": "integratedTerminal",
            "justMyCode": false,
        }
    ]
}

Run Code Online (Sandbox Code Playgroud)

添加目的似乎很重要

我发现这里记录了正确的方法:https ://code.visualstudio.com/docs/python/testing#_debug-tests

  • 你知道,你今天拯救了我的夜晚。:) 希望你有一个好的周末。(“目的”正是我刚才正在寻找的配置 - 谢谢!) (3认同)

Ges*_*ode 12

为此,您需要更改launch.json文件。在launch.json文件中,您必须设置"justMyCode"false

如上所述这里。(有人通过Visual Studio Code网站上的这篇文章指出了该链接。)

  • 这是针对 Visual Studio 完整版本,而不是针对 Visual Studio 代码 (2认同)

小智 12

我向 launch.json 添加了“justMyCode”: false”设置,但它仍然没有在外部库代码中的断点处停止。更令人困惑的是:它确实工作过一次,然后突然不再工作了。

然后我发现:如果您在“运行和调试(SHIFT+CMD+D)”选项卡中并选择您的配置,然后单击绿色三角形/“开始调试(F5)”,它就可以工作!但是,如果我单击右上角的“调试 Python 文件”,它不会停止在外部库代码中!

  • 到底是什么。那行得通。GRRR (5认同)

Dle*_*ans 7

如果您专门调试 Python 单元测试,则添加"justMyCode": "false"到正常配置是行不通的,您需要在 launch.json 中添加另一个"request": "test"

        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false,
        },
Run Code Online (Sandbox Code Playgroud)

来源:Github Microsoft/vscode-python 问题 #7131


小智 5

只是添加"justMyCode": falselaunch.json不起作用。您需要在launch.json下面添加一个单独的配置。仅供参考,每个{}代表一个配置。

"configurations": [
        {
           .... # existing config
        },
        {
            "name": "Debug Unit Test",
            "type": "python",
            "request": "test",
            "justMyCode": false,
        }
    ]
Run Code Online (Sandbox Code Playgroud)

正如这里所指出的

  • 这对我不起作用。它说 justMyCode **不允许属性**(我正在使用 Visual Studio Code 2018) (7认同)
  • 这实际上是我自己问题的答案,但应该注意的是,它特定于 *python* 项目中的 *testing*,而看起来 OP 有兴趣调试 *C#* 项目的 *launch* 。另外,一个[突出的错误](https://github.com/microsoft/vscode-python/issues/14388)(在撰写本文时)指出了更全局地指定启动配置的能力(包括“justMyCode”选项) )通过“settings.json”。(但错误是“justMyCode”当前在调试单元测试的配置中被忽略。) (4认同)
  • @cluis92,编辑说这是不允许的,但事实上它是有效的。 (3认同)