Skip to content

Uno.Sdk still adds Microsoft.Web.WebView2 to desktop heads after the Microsoft.Web.WebView2 backend was removed #25216

Closed

Description

@MartinZikmund

Current behavior

The Uno.Sdk still adds a PackageReference to Microsoft.Web.WebView2 (with Aliases=mswebview2) to every desktop head that uses the webview feature, even though the Microsoft.Web.WebView2-based backend was removed in #23757 (chore: remove Microsoft.Web.WebView2 backend). The Win32 runtime now only uses the AOT backend (WebView2Aot).

The reference, and the two MSBuild workaround targets that exist only to make it work, are still in the SDK:

As a result, every desktop head with the webview feature restores the package and copies its managed assemblies and native loaders into the output, although no Uno 7.0 runtime assembly uses them.

Expected behavior

A desktop head that uses the webview feature should not restore or ship Microsoft.Web.WebView2 once nothing uses it. The package reference, the UnoWebView2Aliases / UnoDisableWebView2Workarounds properties, the two workaround targets, and the MicrosoftWebView2 entry in packages.json can be removed.

How to reproduce it

  1. Create a folder with these files.

    global.json:

    { "msbuild-sdks": { "Uno.Sdk": "7.0.0-dev.67" }, "sdk": { "allowPrerelease": true } }

    App.csproj:

    <Project Sdk="Uno.Sdk">
      <PropertyGroup>
        <TargetFramework>net10.0-desktop</TargetFramework>
        <OutputType>Exe</OutputType>
        <UnoSingleProject>true</UnoSingleProject>
        <UnoFeatures>Hosting;webview</UnoFeatures>
      </PropertyGroup>
      <ItemGroup>
        <!-- Only needed to get past an unrelated duplicate-type error with the current dev packages -->
        <PackageReference Include="Uno.WinUI.Lottie" Version="7.0.0-dev.701" ExcludeAssets="all" />
      </ItemGroup>
    </Project>

    Program.cs:

    public static class Program { public static void Main() { } }

    (The nuget.config points at nuget.org plus the Uno dev feed.)

  2. Run dotnet publish -c Release -o out.

  3. List the output folder.

Result (runtime-verified, nothing is executed, this is a build and publish check):

out\Microsoft.Web.WebView2.Core.dll      698,208 bytes
out\Microsoft.Web.WebView2.Core.xml      612,031 bytes
out\Microsoft.Web.WebView2.WinForms.dll   39,264 bytes
out\Microsoft.Web.WebView2.WinForms.xml   41,869 bytes
out\runtimes\win-x64\native\WebView2Loader.dll    194,912 bytes
out\runtimes\win-x86\native\WebView2Loader.dll    155,488 bytes
out\runtimes\win-arm64\native\WebView2Loader.dll  180,064 bytes

project.assets.json also shows Microsoft.Web.WebView2/1.0.4258.31 being restored. That is roughly 1.3 MB of binaries plus about 650 KB of XML docs in every published webview desktop app. I scanned the assembly references of the published output: no Uno assembly references Microsoft.Web.WebView2.Core (only the app's own App.dll and Microsoft.Web.WebView2.WinForms.dll do). I did not check why App.dll carries the reference; it may be a side effect of the package reference itself.

Workaround

Nothing needed to keep apps working, the extra files are just dead weight. UnoDisableWebView2Workarounds=true only skips the Microsoft.Web.WebView2.Wpf reference removal and the aliasing, it does not stop the package being restored and copied.

Works on UWP/WinUI

N/A (Uno.Sdk packaging issue)

Environment

Other

NuGet package version(s)

Uno.Sdk 7.0.0-dev.67 (newest published 7.0 dev at the time of testing). Source references above are on master at e98c0dcdc36.

Affected platforms

Skia Desktop (Windows, Linux, macOS) with the webview feature

IDE

dotnet CLI

IDE version

.NET SDK 10.0.401

Relevant plugins

No response

Anything else we need to know?

Confirmed by a real publish (above) and by source inspection of the SDK targets on master. Whether any consumer still relies on the mswebview2 alias outside this repo is not something I checked. Within this repo, the only remaining PackageReference to the package is in SamplesApp.csproj and the sync-generator references project.

Activity

  1. added
    kind/bug
    good first issue
    triage/untriaged
    area/webview
    difficulty/starter 🚀
    area/sdk
    platform/desktop 🖥️
    7.0
    on Oct 11, 2026
  2. removed
    triage/untriaged
    7.0
    on Oct 29, 2026
  3. self-assigned this
    on Nov 3, 2026
  4. Xiaoy312 commented on Nov 3, 2026

    @Xiaoy312
    Contributor

    Update after investigating this: the managed part of Microsoft.Web.WebView2 is unused, but the package itself is still needed.

    What is needed. The WebView2Aot backend loads the native WebView2Loader.dll (Win32WebView2Loader.Ensure in Uno.UI.Runtime.Win32). The WebView2Aot package doesn't ship that file; its README says to take it from Microsoft.Web.WebView2. Removing the package reference entirely publishes an app without the loader. On a machine without a stray WebView2Loader.dll on PATH, the Windows WebView then fails at runtime with DllNotFoundException. The build still succeeds. This is easy to miss on a dev box: the Windows Performance Toolkit, for example, puts a WebView2Loader.dll on PATH.

    What is dead weight. Microsoft.Web.WebView2.Core.dll, Microsoft.Web.WebView2.WinForms.dll, their XML docs (about 1.4 MB), and the compile reference that the implicit mswebview2 alias exists for. Today these cost only size: apps build and run normally.

    The workaround targets are still needed. The package adds its managed references by hand, so a normal Aliases setting never reaches Microsoft.Web.WebView2.Core. Without _UnoWebView2Workaround, a project that references Microsoft.Web.WebView2 itself and uses Uno's Microsoft.Web.WebView2.Core types fails to build with CS0433. SamplesApp is one such project.

    Revised expected behavior: a desktop head with the webview feature still restores Microsoft.Web.WebView2, but ships only runtimes/win-*/native/WebView2Loader.dll.

    #25996 does that: the implicit reference becomes IncludeAssets="native" and UnoWebView2Aliases is removed, while the workaround targets and MicrosoftWebView2Version are kept. It was checked with the repro from this issue:

    SDK Managed WebView2 dll/xml shipped WebView2Loader.dll shipped Loader loads (clean PATH)
    Uno.Sdk 7.0.0-dev.67 (published) yes yes yes
    Uno.Sdk 7.0.0-dev.130 (published) yes yes yes
    with #25996 no yes yes
    package removed entirely no no no

    On the open question in the report: the app's own App.dll references Microsoft.Web.WebView2.Core only because of the implicit package reference. With #25996 it no longer does.

    This is a breaking change for apps that used the package's managed API through the implicit mswebview2 alias. They need an explicit <PackageReference Include="Microsoft.Web.WebView2" Aliases="mswebview2" />, as described in the migration guide entry added by #25996.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/sdkarea/webviewdifficulty/starter 🚀good first issuekind/bugplatform/desktop 🖥️

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions