Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] PackageReference to Microsoft.Web.WebView2 in project causes CoreWebView2 name collision when used with Microsoft.WinUI library in WinUI app #4915

Open
matthewacme opened this issue Sep 3, 2024 · 4 comments
Assignees
Labels
needs attention Delete label after triage public-client

Comments

@matthewacme
Copy link

Library version used

4.64.0

.NET version

Microsoft.WindowsAppSDK 1.5.240802000


net8.0-windows10.0.22621.0

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

Upgrading to the latest version of the Microsoft.IdentityClient and Microsoft.Identity.Client.Extensions.Msal (version 4.64.0 for both libraries) in a WinUI app built on the Microsoft.WindowsAppSDK 1.5.240802000 causes the following error on Compile.

error CS0433: The type 'CoreWebView2' exists in both 'Microsoft.Web.WebView2.Core.Projection, Version=1.0.2739.15, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' and 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b'

downgrade to the previous build and the error goes away. My project doesn't have a reference to the Microsoft.Web.WebView2.Core.Projection library, so this reference is getting brought in by MSAL.

see the source in GitHub for the .csproj

Relevant code snippets

No response

Expected behavior

upgrading to the latest library would not break my WinUI app

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

worked in 4.63.0

Solution and workarounds

I've tried everything I can to hide the reference you have added from my projects compile. Until the differing folks and teams at Microsoft can agree on exactly WHERE the WebView2 name spaces are going to live, maybe you could alias it in your project?

@matthewacme matthewacme added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Sep 3, 2024
@iulico-1
Copy link
Contributor

iulico-1 commented Sep 4, 2024

@matthewacme, are you trying to enable auth for native AAD auth or B2C /external ID ?

@matthewacme
Copy link
Author

matthewacme commented Sep 4, 2024

@iulico-1 The current build of my app, using the following project definition and package references of

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
    <TargetPlatformMinVersion>10.0.19044.0</TargetPlatformMinVersion>
    <LangVersion>latest</LangVersion>
    <RootNamespace>MyRadar.WinUI.Services</RootNamespace>
    <RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
    <UseWinUI>true</UseWinUI>
    <SupportedOSPlatformVersion>10.0.20348.0</SupportedOSPlatformVersion>
    <Platforms>x86;x64;ARM64</Platforms>
    <Nullable>enable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
  </PropertyGroup>
...

  <ItemGroup>
      <PackageReference Include="AutoMapper" Version="13.0.1" />
      <PackageReference Include="AzureMapsRestToolkit" Version="7.1.0" />
      <PackageReference Include="Microsoft.Identity.Client" Version="4.63.0" />
      <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240802000" />
      <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.3233" />
      <PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.8" />
  </ItemGroup>

Allows me to currently USE B2C / external ID, that is we are able to currently allow our users to create and use MSAL to set up B2C registration / login / identity with our AD system.

As soon as I attempt update the Microsoft.Identity.Client to 4.64.0 (from 4.63.0) I get the compile error. Upgrading the other references does not "fix" the issue.

@charlesroddie
Copy link

Duplicate of #4826

Try WinAppSDK 1.6 which was released just after this issue was posted.
https://blogs.windows.com/windowsdeveloper/2024/09/04/whats-new-in-windows-app-sdk-1-6/
"Decoupled WebView2 versioning"

@matthewacme
Copy link
Author

@charlesroddie
Unfortunately it is not possible to upgrade to the WinAppSDK 1.6. I tried that about 2 weeks ago, and the bugs that upgrade introduced were so extensive that our app would not run.

I filed various bugs with the WinAppSDK team in regards to the issues that were raised with an attempt to upgrade to 1.6.

I'm going to have to wait until at least their next release / bug fix for 1.6 before I can upgrade

@iulico-1 iulico-1 removed the untriaged Do not delete. Needed for Automation label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs attention Delete label after triage public-client
Projects
None yet
Development

No branches or pull requests

4 participants