You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/spfx/debug-in-vscode.md
+58-1Lines changed: 58 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -102,7 +102,7 @@ When building SharePoint Framework solutions that communicate with SharePoint, y
102
102
103
103
When building SharePoint Framework solutions, you will be doing such tests regularly, and it is a good idea to create a separate debug configuration for the hosted version of the SharePoint Workbench.
104
104
105
-
### Debug solution using hosted workbench
105
+
### Debug Web Part solution using hosted workbench
106
106
107
107
1. Open launch.json, and update the `url` property under the *Hosted workbench* configuration to your SharePoint site URL.
108
108
@@ -122,6 +122,63 @@ When building SharePoint Framework solutions, you will be doing such tests regul
122
122
123
123

124
124
125
+
### Debug Extension solution using hosted workbench
126
+
127
+
Debuging an Extension in a hosted workbench is very similar to the steps for a Web Part with a few key differences.
128
+
129
+
130
+
1. Open launch.json, and update the `url` property under the *Hosted workbench* configuration to your SharePoint site URL.
2. In Visual Studio Code, activate the **Debug** pane, and in the **Configurations** list, selectthe newly added **Hosted workbench** configuration.
137
+
138
+

139
+
140
+
3. After initiating the gulp serve in the Terminal start debugging either by selecting F5 or by selecting the **Start Debugging** option on the **Debug** menu. Visual Studio Code switches into debug mode, indicated by the orange status bar, and the Debugger for Chrome extension opens a new instance of Google Chrome with the Office 365 sign-in page.
141
+
142
+

143
+
144
+
4. In the workbench tab that was opened in your browser navigate to a SharePoint Online page that you wish to test your extension.
145
+
146
+
5. Append the following query string parameters to the URL. Notice that you need to update the ID to match your own extension identifier. This is available in the **HelloWorldApplicationCustomizer.manifest.json** file.
147
+
148
+
```json
149
+
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"e5625e23-5c5a-4007-a335-e6c2c3afa485":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
150
+
```
151
+
152
+
More detail about the URL query parameters:
153
+
154
+
***loadSPFX=true**. Ensures that the SharePoint Framework is loaded on the page. For performance reasons, the framework does not load unless at least one extension is registered. Because no components are registered, you must explicitly load the framework.
155
+
156
+
***debugManifestsFile**. Specifies that you want to load SPFx components that are locally served. The loader only looks forcomponentsin the app catalog (for your deployed solution) and the SharePoint manifest server (for the system libraries).
157
+
158
+
***customActions**. Simulates a custom action. When you deploy and register this component in a site, you'll create this **CustomAction** object and describe all the different properties you can set on it.
159
+
* **Key**. Use the GUID of the extension as the key to associate with the custom action. This has to match the ID value of your extension, which is available in the extension manifest.json file.
160
+
* **Location**. The type of custom action. Use `ClientSideExtension.ApplicationCustomizer` for the Application Customizer extension.
161
+
* **Properties**. An optional JSON object that contains properties that are available via the **this.properties** member. In this HelloWorld example, it defined a `testMessage` property.
162
+
163
+
The full URL should look similar to the following:
164
+
165
+
```json
166
+
contoso.sharepoint.com/Lists/Contoso/AllItems.aspx?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js&customActions={"e5625e23-5c5a-4007-a335-e6c2c3afa485":{"___location":"ClientSideExtension.ApplicationCustomizer","properties":{"testMessage":"Hello as property!"}}}
167
+
```
168
+
169
+
6. Select **Load debug scripts** to continue loading scripts from your local host.
170
+
171
+

172
+
173
+
<br/>
174
+
When the page loads you should now be able to see the Extension on your page(in this case a list view command extension):
175
+
176
+

177
+
178
+
In addition you can now toggle Breakpoints and step through the code:
179
+
180
+

181
+
125
182
## Debugging with Microsoft Edge or older projects
126
183
127
184
If you are using an older version of SharePoint Framework Yeoman generator or want to debug with Microsoft Edge, follow these steps to create the launch.json file manually.
0 commit comments