.netwpfwebview2chrome-devtools-protocol

WebView2: must I install Microsoft.Web.WebView2.DevToolsProtocolExtension?


In this tutorial about using the Chromium devtools protocol from WebView2 it says the Microsoft.Web.WebView2.DevToolsProtocolExtension nuget package is necessary.

Is it still necessary (August 2021)?

The simple stuff I'm doing to interact with devtools (retrieve logs and console.*() information) works just fine without it. And that package pulls in a whole mess of other packages, which will make my app a little heavier.

Can I safely omit the extension nuget package?


Solution

  • TLDR: No you don't

    The tutorial notes that to use the Chromium DevTools Protocol APIs in WebView2, you can use either:

    The nuget package is not necessary. It exists just to make things easier for you as it turns all the JSON objects into actual objects with types that you can see in IntelliSense and so on.

    Instead you can directly use CoreWebView2.CallDevToolsProtocolMethod and CoreWebView2.GetDevToolsProtocolEventReceiver, parse the JSON responses yourself, and produce the JSON requests yourself.