在未安装 MicrosoftEdgeWebView2 的情况下使用 VS Code 调试 Excel 加载项

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

我正在尝试将我的开发环境迁移到 VSCode,到目前为止,如果我安装了

MicrosoftEdgeWebView2
,我就无法让它工作。

我已经安装了“Microsoft Office Add-in Debugger”,我认为这是我需要使用的。它显示已弃用/废弃,但它也是 Google 中 MSFT 调试加载项的最佳结果... https://learn.microsoft.com/en-us/office/dev/add-ins/testing/debug-带-与-扩展

这是我的

tasks.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Debug: Excel Desktop",
      "type": "npm",
      "script": "start:desktop -- --app excel",
      "presentation": {
        "clear": true,
        "panel": "dedicated",
      },
      "problemMatcher": []
    },
    {
      "label": "Stop Debug",
      "type": "npm",
      "script": "stop",
      "presentation": {
        "clear": true,
        "panel": "shared",
        "showReuseMessage": false
      },
      "problemMatcher": []
    },
  ]
}

launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Excel Desktop (Edge Chromium)",
      "type": "msedge",
      "request": "attach",
      "port": 9229,
      "timeout": 600000,
      "webRoot": "${workspaceRoot}",
      "preLaunchTask": "Debug: Excel Desktop",
      "postDebugTask": "Stop Debug"
    },
    {
      //https://learn.microsoft.com/en-us/office/dev/add-ins/testing/debug-desktop-using-edge-chromium#appendix-b
      "name": "Excel PWA Desktop (Edge Chromium)",
      "type": "pwa-msedge",
      "request": "attach",
      "useWebView": true,
      "port": 9229,
      "timeout": 600000,
      "webRoot": "${workspaceRoot}",
      "preLaunchTask": "Debug: Excel Desktop",
      "postDebugTask": "Stop Debug"
   },
    {
      "name": "Excel Desktop (Edge Legacy)",
      "type": "office-addin",
      "request": "attach",
      "url": "https://localhost:3000/index.html?_host_Info=Excel$Win32$16.01$en-US$$$$0",
      "port": 9229,
      "timeout": 600000,
      "webRoot": "${workspaceRoot}",
      "preLaunchTask": "Debug: Excel Desktop",
      "postDebugTask": "Stop Debug"
    },
  ]
}

注意:网上经常显示端口

9222
,但我发现至少当我切换到
9229
时,它并没有开始重复说
Edge Instance: []
,但没有用,我都尝试过。

另请注意,我已经切换到

index.html
,但只要它正确就没关系..

我已经在两个端口上尝试了以下所有变体:

npx office-addin-dev-settings webview .\manifest.xml edge
npx office-addin-dev-settings webview .\manifest.xml edge-chromium
npx office-addin-dev-settings webview .\manifest.xml edge-legacy
npx office-addin-dev-settings webview .\manifest.xml ie
npx office-addin-dev-settings webview .\manifest.xml default

有什么想法可以在不安装

MicrosoftEdgeWebView2
的情况下调试 Excel Office-JS 加载项吗?

当我安装了 MicrosoftEdgeWebView2 时,我确实让它与我的清单一起工作,所以我知道我的清单/网络服务器等正在工作并正确设置。

excel visual-studio-code office-js vscode-debugger
1个回答
0
投票

嗯,本质上,当我卸载 MicrosoftEdgeWebView2 时,它会强制应用程序使用 IE 作为渲染引擎。

没有任何用于调试 IE 的官方 VSCode 扩展。

我能得到的最好的结果是在启动 Excel/Webserver 等后自动打开 F12 或 IEChooser.exe。

https://learn.microsoft.com/en-us/office/dev/add-ins/testing/debug-add-ins-using-f12-tools-ie

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