Page 34 - MSDN Magazine, October 2017
P. 34
WINDOWS DEVICE PORTAL
Write a Windows Device
Portal Packaged Plug-in
Scott Jones
Amid the fanfare of the Windows 10 release, one feature made a quiet debut: Windows Device Portal (WDP). WDP is a Web-based diagnostic system built into Windows 10. After a progressive roll- out, WDP is now available on HoloLens, IoT, Mobile, Desktop and Xbox. It’s expected to be included in new editions of Windows as they’re released. With the exception of Windows Desktop, WDP is immediately available out of the box. On Desktop, WDP is avail- able with the download and installation of the optional Windows Update Developer Mode package. In this article, I’ll show you how to use the WDP API to implement a WDP packaged plug-in to extend your Windows Store app with custom REST APIs. While the focus of this article is on the Windows Desktop, the concepts and techniques also apply to other Windows editions.
To create and execute a WDP packaged plug-in, you’ll need to update your system to at least the Windows 10 Creators Update
(10.0.15063.0), and install the corresponding Windows 10 SDK (bit.ly/2tx5Bnk). For detailed instructions, see the article, “Updating Your Tooling for Windows 10 Creators Update” (bit.ly/2tx3FeD). It might be necessary to restart the machine for Visual Studio to de- tect and support the new SDK; otherwise projects may fail to load.
If you’re not familiar with WDP, I encourage you to read the article, “Windows Device Portal Overview” (bit.ly/2uG9rco). This will provide an introduction to the features of WDP, and will also ensure that you have it installed before proceeding with writing a packaged plug-in.
Briefly, you’ll need to download and install the optional Devel- oper Mode package. From the Settings app (press Windows+I), navigate to the Update & security | For developers page, and select the Developer mode radio button. When the Developer Mode package installation is complete, check the Enable Device Portal checkbox, set credentials as desired, and browse to the supplied URL to verify functionality. After accepting the WDP self-signed certificate and entering credentials, the browser should display the WDP Web UI, as shown in Figure 1.
WDP Architecture
The tools presented in the WDP UI in Figure 1 are implemented with JavaScript controls that communicate with REST APIs hosted in the WDP Service. As REST APIs, these generalized, stateless Web requests are applicable in more contexts than just the WDP UI. For example, a WDP REST API could be called from a Windows PowerShell script or a custom user agent. The
This article discusses:
• WDP architecture
• Writing a packaged plug-in
• Testing and deploying a packaged plug-in
Technologies discussed:
Windows Device Portal, C#, Universal Windows Platform, WinRT, HTTP
Code download available at:
bit.ly/2tTPFMV
30 msdn magazine