WebView2.Runtime icon indicating copy to clipboard operation
WebView2.Runtime copied to clipboard

Referencing WebView2.Runtime adds dependency to Microsoft.VCLibs.140.00 and Microsoft.VCLibs.140.00.UWPDesktop

Open lfderm opened this issue 1 year ago • 6 comments

When the WebView2.Runtime package is added to WinUI a project, then the following dependencies are added to the project's publish output appx package:

    <PackageDependency Name="Microsoft.VCLibs.140.00" MinVersion="14.0.33519.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>
    <PackageDependency Name="Microsoft.VCLibs.140.00.UWPDesktop" MinVersion="14.0.33728.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"/>

We intended to add WebView2 Runtime to allow a self-contained deployment without any dependencies. Now we get two new dependencies added, which we would need to manually install on target machines. Newer Windows builds happen to include them already, but older ones (e.g. 22H2) do not have them and need manual installation.

Are these really needed? WinUI 3 does not need them anymore due to Hybrid CRT. They are still added by default, but they are unnecessary and can be removed by a property switch. Can you check if they are really still needed for WebView2? Maybe they can be removed here as well?

lfderm avatar Nov 27 '24 11:11 lfderm

Seems they still includes this stuff for backwards compatibility. I think WinUISDKReferences flag can be changed for UAP target, need to test that.

ProKn1fe avatar Nov 27 '24 12:11 ProKn1fe

Yes, by default they still add the dependencies, although they are not used anymore. I fail to understand the logic why they are still adding the dependency. But anyways, it can be easily disabled like this:

<WinUISDKReferences>false</WinUISDKReferences>

If WebView2 also does not need it, it would be great if it can be removed as well, to be able to really ship a 100% self contained application.

lfderm avatar Nov 27 '24 12:11 lfderm

Or alternatively, if the dependencies are really required, then maybe it would be possible to just include the dlls from the corresponding appx package into the WebView2 runtime folder? The appx packages are located here (e.g. for the .Desktop x64 appx): %ProgramFiles(x86)%\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs.Desktop\14.0\Appx\Retail\x64

lfderm avatar Nov 27 '24 12:11 lfderm

It seems WebView2 themself also adds Microsoft.VCLibs reference. image

ProKn1fe avatar Nov 27 '24 13:11 ProKn1fe

I cannot confirm that. If I only reference WebView2 without WebView2.Runtime, then I don't have a dependency on it in the generated appx file. The dependency only comes if I add WebView2.Runtime.

lfderm avatar Nov 27 '24 13:11 lfderm

When I look into the WebView2 folder, I see multiple C Runtime dlls. So I am pretty confident that the VCLibs dependency is in fact not needed. The WebView2 Rruntime brings everything that is required. And as I said before, the WebView2 package does not have these dependencies. If I remove WebView2.Runtime and publish (using <WinUISDKReferences>false</WinUISDKReferences>), I have zero dependencies.

lfderm avatar Dec 06 '24 11:12 lfderm