Skip to content

Commit c96589f

Browse files
authored
Merge pull request #5049 from OfficeDev/refresh-VS-debugging
[All Hosts] (debugging) refresh VS debugging
2 parents 5878423 + 2dc8ecd commit c96589f

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

docs/develop/debug-office-add-ins-in-visual-studio.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Debug Office Add-ins in Visual Studio
33
description: Use Visual Studio to debug Office Add-ins in the Office desktop client on Windows.
4-
ms.date: 02/12/2025
4+
ms.date: 02/19/2025
55
ms.localizationpriority: medium
66
---
77

@@ -14,7 +14,7 @@ This article describes how to debug client-side code in Office Add-ins that are
1414
1515
## Review the build and debug properties
1616

17-
Before you start debugging, review the properties of each project to confirm that Visual Studio will open the desired Office application and that other build and debug properties are set appropriately.
17+
Before you start debugging, review the properties of each project in the solution to confirm that Visual Studio will open the desired Office application and that other build and debug properties are set appropriately.
1818

1919
### Add-in project properties
2020

@@ -84,6 +84,9 @@ When Visual Studio builds the project, it performs the following tasks:
8484
> [!NOTE]
8585
> If Office uses the Edge Legacy webview control (EdgeHTML) to run add-ins on your Windows computer, Visual Studio may prompt you to add a local network loopback exemption. This is required for the webview control to be able to access the website deployed to the local IIS web server. You can also change this setting anytime in Visual Studio under **Tools** > **Options** > **Office Tools (Web)** > **Web Add-In Debugging**. To find out what webview control is used on your Windows computer, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
8686
87+
> [!TIP]
88+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
89+
8790
Next, Visual Studio does the following:
8891

8992
1. Modifies the [SourceLocation](/javascript/api/manifest/sourcelocation) element of the add-in only manifest file (that was copied to the `_ProjectName_\bin\Debug\OfficeAppManifests` directory) by replacing the `~remoteAppUrl` token with the fully qualified address of the start page (for example, `https://localhost:44302/Home.html`).
@@ -99,7 +102,10 @@ Next, Visual Studio does the following:
99102

100103
### Debug the add-in
101104

102-
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md). If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the desktop](#use-the-built-in-visual-studio-debugger-to-debug-on-the-desktop). For any other webview control, see [Use the browser developer tools to debug on the desktop](#use-the-browser-developer-tools-to-debug-on-the-desktop).
105+
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the desktop](#use-the-built-in-visual-studio-debugger-to-debug-on-the-desktop). For any other webview control, see [Use the browser developer tools to debug on the desktop](#use-the-browser-developer-tools-to-debug-on-the-desktop). To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
106+
107+
> [!TIP]
108+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
103109
104110
#### Use the built-in Visual Studio debugger to debug on the desktop
105111

@@ -117,15 +123,7 @@ The best method for debugging an add-in in Visual Studio 2022 depends on whether
117123

118124
1. Follow the steps in the earlier section [Start the add-in project](#start-the-add-in-project).
119125

120-
1. Launch the add-in in the Office application if it isn't already open. For example, if it's a task pane add-in, it'll have added a button to the **Home** ribbon (for example, a **Show Taskpane** button). Select the button on the ribbon.
121-
122-
> [!NOTE]
123-
> If your add-in isn't sideloaded by Visual Studio, you can sideload it manually. Follow the instructions to [Sideload an Office Add-in for testing](../testing/test-debug-office-add-ins.md#sideload-an-office-add-in-for-testing) for your platform.
124-
>
125-
> In the list of available add-ins, find the **Developer Add-ins** section and select the your add-in to register it.
126-
127-
> [!TIP]
128-
> The task pane may appear blank when it first opens. If so, it should render correctly when you launch the debugging tools in a later step.
126+
1. Launch the add-in in the Office application if it isn't already open. For example, if it's a task pane add-in, it'll have added a button (for example, a **Show Taskpane** button) to the **Home** ribbon or to a custom ribbon tab that's installed with the add-in. Select the button on the ribbon.
129127

130128
1. Open the [personality menu](../design/task-pane-add-ins.md#personality-menu) and then choose **Attach a debugger**. This action opens the debugging tools for the webview control that Office is using to run add-ins on your Windows computer. You can set breakpoints and step through code as described in one of the following articles:
131129

@@ -186,9 +184,15 @@ Next, Visual Studio does the following:
186184
187185
1. Opens the Office application host page of your Microsoft 365 tenancy in Microsoft Edge.
188186

187+
> [!TIP]
188+
> If for any reason, Visual Studio doesn't fully sideload the add-in and none of the fixes earlier works, you can manually sideload it. Follow the steps in [Sideload an add-in to Microsoft 365](../testing/sideload-office-add-ins-for-testing.md#sideload-an-add-in-to-microsoft-365). When you're instructed to browse to the manifest, navigate to the XML file in the folder `_ProjectName_\bin\Debug\OfficeAppManifests` directory.
189+
189190
### Debug the add-in on the web
190191

191-
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md). If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the web](#use-the-built-in-visual-studio-debugger-to-debug-on-the-web). For any other webview control, see [Use the browser developer tools to debug on the web](#use-the-browser-developer-tools-to-debug-on-the-web).
192+
The best method for debugging an add-in in Visual Studio 2022 depends on whether the add-in is running in WebView2, which is the webview control that is associated with Microsoft Edge (Chromium), or an older webview control. If your computer is using WebView2, see [Use the built-in Visual Studio debugger to debug on the web](#use-the-built-in-visual-studio-debugger-to-debug-on-the-web). For any other webview control, see [Use the browser developer tools to debug on the web](#use-the-browser-developer-tools-to-debug-on-the-web). To determine which webview control is being used, see [Browsers and webview controls used by Office Add-ins](../concepts/browsers-used-by-office-web-add-ins.md).
193+
194+
> [!TIP]
195+
> [!INCLUDE[Identify the webview through the add-in UI](../includes/identify-webview-in-ui.md)]
192196
193197
#### Use the built-in Visual Studio debugger to debug on the web
194198

@@ -219,7 +223,7 @@ The best method for debugging an add-in in Visual Studio 2022 depends on whether
219223
> [!TIP]
220224
> To debug code that runs in the `Office.initialize` function or an `Office.onReady` function that runs when the add-in opens, set your breakpoints, and then close and reopen the add-in. For more information about these functions, see [Initialize your Office Add-in](../develop/initialize-add-in.md).
221225
222-
1. To make changes to your code, first stop the debugging session in Visual Studio and close the Outlook pages. Make your changes, and start a new debugging session.
226+
1. To make changes to your code, first stop the debugging session in Visual Studio and close the Office on the web page. Make your changes, and start a new debugging session.
223227

224228
## Use an existing document to debug the add-in
225229

0 commit comments

Comments
 (0)