DotnetRuntimeBootstrapper
DotnetRuntimeBootstrapper copied to clipboard
Add support for WebView2 runtime prerequisite
Details
Some applications might depend on having WebView2 installed on user machine, and Microsoft actively tries to push developers to use it, deprecating (or even already breaking/removing) older native browser interops (IE is old, and Edge from 2015 doesn't have working wrapper for .NET anymore). At the same time, of course, WebView2 runtime is not preinstalled on Windows devices before Spring 2021 update.
Saying that, having WebView2 installed automatically is really helpful feature.
I guess it would be nice to have a way to specify additional dependencies to the bootstrapper, on top of .NET runtime. Could be done through the .runtimeconfig.json that we're reading already anyway.
Out of curiosity, what is the .runtimeconfig.json generated for a project that uses WebView2?
I've added WebView2 to the demo project (from this project) and nothing changed in the DotnetRuntimeBootstrapper.Demo.runtimeconfig.json file.
There are changes in DotnetRuntimeBootstrapper.Demo.deps.json file:
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"DotnetRuntimeBootstrapper.Demo/1.2.3": {
"dependencies": {
"DotnetRuntimeBootstrapper": "2.0.3",
"Microsoft.Web.WebView2": "1.0.1054.31"
},
"runtime": {
"DotnetRuntimeBootstrapper.Demo.dll": {}
}
},
"Microsoft.Web.WebView2/1.0.1054.31": {
"runtime": {
"lib/netcoreapp3.0/Microsoft.Web.WebView2.Core.dll": {
"assemblyVersion": "1.0.1054.31",
"fileVersion": "1.0.1054.31"
},
"lib/netcoreapp3.0/Microsoft.Web.WebView2.WinForms.dll": {
"assemblyVersion": "1.0.1054.31",
"fileVersion": "1.0.1054.31"
},
"lib/netcoreapp3.0/Microsoft.Web.WebView2.Wpf.dll": {
"assemblyVersion": "1.0.1054.31",
"fileVersion": "1.0.1054.31"
}
},
"runtimeTargets": {
"runtimes/win-arm64/native/WebView2Loader.dll": {
"rid": "win-arm64",
"assetType": "native",
"fileVersion": "1.0.1054.31"
},
"runtimes/win-x64/native/WebView2Loader.dll": {
"rid": "win-x64",
"assetType": "native",
"fileVersion": "1.0.1054.31"
},
"runtimes/win-x86/native/WebView2Loader.dll": {
"rid": "win-x86",
"assetType": "native",
"fileVersion": "1.0.1054.31"
}
}
},
"DotnetRuntimeBootstrapper/2.0.3": {
"runtime": {
"DotnetRuntimeBootstrapper.dll": {}
}
},
"Microsoft.Build.Utilities.Core/15.1.0.0": {
"runtime": {
"Microsoft.Build.Utilities.Core.dll": {
"assemblyVersion": "15.1.0.0",
"fileVersion": "16.11.0.36601"
}
}
},
"Microsoft.Build.Framework/15.1.0.0": {
"runtime": {
"Microsoft.Build.Framework.dll": {
"assemblyVersion": "15.1.0.0",
"fileVersion": "16.11.0.36601"
}
}
},
"Microsoft.NET.StringTools/1.0.0.0": {
"runtime": {
"Microsoft.NET.StringTools.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.26302"
}
}
}
}
},
"libraries": {
"DotnetRuntimeBootstrapper.Demo/1.2.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Web.WebView2/1.0.1054.31": {
"type": "package",
"serviceable": true,
"sha512": "sha512-YKIqNAtxgvOZIKj97C5o0EtISEUtVnEsVCJyWHdRTVT6/ldtxxQaEeX55Dw9nFvyKWruvOlhub0QQBv69D4tbA==",
"path": "microsoft.web.webview2/1.0.1054.31",
"hashPath": "microsoft.web.webview2.1.0.1054.31.nupkg.sha512"
},
"DotnetRuntimeBootstrapper/2.0.3": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.Build.Utilities.Core/15.1.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.Build.Framework/15.1.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Microsoft.NET.StringTools/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}
After some deliberation, I've decided not to add WebView2 runtime bootstrapping to DotnetRuntimeBootstrapper for the following reasons:
- Unlike all the other dependencies that DRB installs, the WebView2 runtime is not essential for the application to run. It means that the application can still start, detect if the runtime is missing, and then direct the user to install it on its own, before initializing any WebView2-dependent functionality.
- Microsoft appears to be quite stringent about WV2 runtime distribution options. Judging by this page, it seems they only encourage using the Evergreen Bootstrapper for programmatic installations. This is not great, as we wouldn't be able to control the version of the runtime that is being installed (which may be different than what the application needs). For the other options, they don't provide a permanent download link that could be embedded in DRB. Specifically, the fixed-version download options (which would likely be the ideal choice for DRB) also seem to expire as new versions are released, meaning that it wouldn't be possible to hard-code the download links even if they were provided.
- There does not seem to be a deterministic way to detect which WV2 runtime an application is relying on. Currently, it seems that the
Microsoft.Web.WebView2package version (which can be extracted from*.deps.jsonor during build-time) does match the version of the runtime, but I couldn't find any documentation on that. This convention may or may not be upheld in the future. Additionally, the user may use a different package that wraps WebView2 which may not even rely onMicrosoft.Web.WebView2.
Ultimately, I think that the WebView2 runtime is a bit too different from the other dependencies that DotnetRuntimeBootstrapper currently takes care of. I don't want DRB to become a catch-all installer for all things that the app may need, as that could be too difficult to maintain. Currently, it only installs the dependencies that are required for the app to start (i.e. .NET runtime and its own prerequisites) and nothing more. I think this is a reasonable scope.