Рет қаралды 3,550
In this demo I attach a debugger session from within Visual Studio Code to an OfficeJS Office Add-in.
Prereq:
OfficeJS Add-in (for instance generated by Yeoman ... yo office)
Visual Studio Code Extension installed:
Microsoft Office Add-in Debugger for Visual Studio Code
marketplace.vi...
Steps:
- Open Admin Command (Start Menu, type Command, right click, Run As Administrator)
- Goto OfficeJS repo
- Start Visual Studio Code to open the repo directory
- Add configuration to launch.json:
{
"type": "office-addin",
"request": "attach",
"name": "Attach to Office Add-ins",
"port": 9222,
"trace": "verbose",
"url": "localhost:3000/taskpane.html?_host_Info=Excel$Win32$16.01$en-US$$$$0",
"webRoot": "${workspaceFolder}",
"timeout": 45000
}
Note: I selected Excel as host so _host_info should contain Excel as in example above.
- Start Terminal in VS Code
- Make sure the Webview is using Edge (not Edge Chromium) using the command:
npx office-addin-dev-settings webview .\manifest.xml edge
This should output:
The web view type is set to Edge.
- Verify the used webview using the command:
npx office-addin-dev-settings webview .\manifest.xml
This should output:
The web view type is set to Edge.
- run command: npm start
This should start a Node window as web server and Excel as host application
- Wait for Node to complete compiling
- Open the TaskPane
- Attach VS Code Debugger by:
- Hit Ctrl-Shift-D
- Select Attach to Office Add-Ins from dropdown list
- Click the green run arrow (or hit Run-Start Debugging from the menu)
- Check the Debug Console output to see if debugger attached properly
- Place a breakpoint in (for instance Taskpane.js) your .js file
- Run your code and verify the breakpoint will hit and code stopped at the breakpoint.
#OfficeDev #OfficeJS #Debugging