dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.26k stars 1.76k forks source link

WMC1006 compile error for Windows MAUI .NET 9 project when referencing Microsoft.Identity.Client.Desktop #25883

Open superwilly1 opened 6 days ago

superwilly1 commented 6 days ago

Description

https://github.com/dotnet/windowsdesktop/issues/4789

Our app uses MSAL to login, using the Microsoft.Identity.Client packages. This used to work in .NET8, but we updated our app to .NET9 now, and on Windows we get compile errors:

Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: System.Xaml, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.'
Could not copy the file "C:\temp\NET9MAUIWindowsIssue\NET9MAUIWindowsIssue\obj\Debug\net9.0-windows10.0.19041.0\win10-x64\Platforms\Windows\App.xbf" because it was not found.

Steps to Reproduce

  1. Create a new MAUI project.
  2. Add a NuGet package reference to Microsoft.Identity.Client.Desktop: <PackageReference Include="Microsoft.Identity.Client.Desktop" Version="4.66.2" />
  3. Note that the app cannot be compiled on Windows.

This zip file contains the above steps, just compile it on Windows and notice the compile errors: NET9MAUIWindowsIssue.zip

I am not sure if this is an issue with MAUI or with Microsoft.Identity.Client, but since it worked on MAUI with .NET8, I assume it is a MAUI related issue. Also created an issue for Microsoft.Identity.Client: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/4993

Link to public reproduction project repository

No response

Version with bug

.NET 9 and WinUI I'm able to reproduce this on a blank WinUI APP

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.93 SR9.3

Affected platforms

Windows

Affected platform versions

Windows SDK 10.0.19041.0

Did you find any workaround?

No workaround found yet.

Relevant log output

1>------ Build started: Project: NET9MAUIWindowsIssue, Configuration: Debug Any CPU ------
1>C:\temp\NET9MAUIWindowsIssue\NET9MAUIWindowsIssue\NET9MAUIWindowsIssue.csproj : XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: System.Xaml, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.'
1>Skipping analyzers to speed up the build. You can execute 'Build' or 'Rebuild' command to run analyzers.
1>C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(5322,5): error MSB3030: Could not copy the file "C:\temp\NET9MAUIWindowsIssue\NET9MAUIWindowsIssue\obj\Debug\net9.0-windows10.0.19041.0\win10-x64\Platforms\Windows\App.xbf" because it was not found.
1>Done building project "NET9MAUIWindowsIssue.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 11:06 and took 06,247 seconds ==========
DevDachi commented 6 days ago

We're encountering the same issue that's hindering our .NET 9 migration

2>C:\repos\MauiApp1\MauiApp1\MauiApp1.csproj : XamlCompiler error WMC1006: Cannot resolve Assembly or Windows Metadata file 'Type universe cannot resolve assembly: System.Xaml, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.' 2>CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point 2>C:\repos\MauiApp1\MauiApp1\Platforms\Windows\App.xaml.cs(19,18,19,37): error CS1061: 'App' does not contain a definition for 'InitializeComponent' and no accessible extension method 'InitializeComponent' accepting a first argument of type 'App' could be found (are you missing a using directive or an assembly reference?)

Zhanglirong-Winnie commented 3 days ago

This issue has been verified using Visual Studio 17.13 Preview 1( 9.0.10 & 8.0.93 & 8.0.100). Can repro this issue on Windows platform. And 8.0.100 & 8.0.93 work fine.

PureWeen commented 3 days ago

I'm able to reproduce this issue on a blank WinUI app (without MAUI)

So, pretty sure this issue has nothing to do with MAUI directly.

I'm leaving this open and assigned it to SR2 for now so that we maintain visibility on this one.

PureWeen commented 6 hours ago

https://github.com/dotnet/windowsdesktop/issues/4789