F5 在 Vscode 扩展开发中不起作用

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

我正在为 Vscode 创建一个新的扩展。我正在遵循“您的第一个扩展”指南。 当我按 F5 绝对没有任何反应。

我的系统是:

  • vscode 版本 1.76.0
  • windows 11 x64
  • 节点版本 v18.12.1
  • npm 版本 9.2.0

我已经检查过的东西:

  • 节点已安装。
  • Yo-code 已安装。
  • VSCE 已安装。
  • 我在我的扩展程序的根目录中。
  • 关闭并重新打开 Vscode.
  • 这个问题没有解决我的问题

我该怎么做才能使 F5 正常工作?

我还没有更改文件中的任何内容。 这是我的文件:

启动.json

// A launch configuration that compiles the extension and then opens it inside a new window
// 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": "Run Extension",
            "type": "extensionHost",
            "request": "launch",
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}"
            ],
            "outFiles": [
                "${workspaceFolder}/out/**/*.js"
            ],
            "preLaunchTask": "${defaultBuildTask}"
        },
        {
            "name": "Extension Tests",
            "type": "extensionHost",
            "request": "launch",
            "args": [
                "--extensionDevelopmentPath=${workspaceFolder}",
                "--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
            ],
            "outFiles": [
                "${workspaceFolder}/out/test/**/*.js"
            ],
            "preLaunchTask": "${defaultBuildTask}"
        }
    ]
}

tasks.json

// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "npm",
            "script": "watch",
            "problemMatcher": "$tsc-watch",
            "isBackground": true,
            "presentation": {
                "reveal": "never"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}

package.json

{
  "name": "xxxxx",
  "displayName": "xxxxx",
  "description": "xxxxx",
  "version": "0.0.1",
  "engines": {
    "vscode": "^1.76.0"
  },
  "categories": [
    "Other"
  ],
  "activationEvents": [],
  "main": "./out/extension.js",
  "contributes": {
    "commands": [
      {
        "command": "xxxxx",
        "title": "Hello World"
      }
    ]
  },
  "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./",
    "watch": "tsc -watch -p ./",
    "pretest": "npm run compile && npm run lint",
    "lint": "eslint src --ext ts",
    "test": "node ./out/test/runTest.js"
  },
  "devDependencies": {
    "@types/vscode": "^1.76.0",
    "@types/glob": "^8.1.0",
    "@types/mocha": "^10.0.1",
    "@types/node": "16.x",
    "@typescript-eslint/eslint-plugin": "^5.53.0",
    "@typescript-eslint/parser": "^5.53.0",
    "eslint": "^8.34.0",
    "glob": "^8.1.0",
    "mocha": "^10.2.0",
    "typescript": "^4.9.5",
    "@vscode/test-electron": "^2.2.3"
  }
}

visual-studio-code debugging vscode-extensions
1个回答
0
投票

由于您的问题可能与 更新到 1.76 后我无法在 VSCode 中构建我的 VSCode 扩展项目我强烈建议您在那里添加您的信息,以防原始 OP 不响应请求更多信息和帮助开发人员弄清楚发生了什么。

与此同时,您可能想降级到 v1.75.2 并查看它是否在那里工作。顺便说一句,在 v1.76 中启动扩展的调试会话对我来说仍然有效,所以你的特定信息在这个问题中很有价值。

我正在添加我的启动配置以进行比较:

        {
            "name": "Run Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [
                "${workspaceFolder}/../OneDrive/TestMultiRoot",  // this is what the ExtensionHost will open
                "--extensionDevelopmentPath=${workspaceFolder}"
            ]
        }

它与你的完全不同,也许我使用的是旧版本的

yo
生成器?您可以尝试将其复制到您的
launch.json
中并注释掉您当前的版本,看看是否会发生任何事情。

© www.soinside.com 2019 - 2024. All rights reserved.