maui
maui copied to clipboard
Visual Studio 17.11.5 causes Windows MAUI to break build
Description
Following on from issue: https://github.com/dotnet/maui/issues/25132
Since installing 17.11.5, all of our MAUI builds are failing for Windows with errors along the lines of:
The type 'CoreWebView2' exists in both 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' and 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b' obj\Debug\net8.0-windows10.0.19041.0\win10-x64\intermediatexaml\WinRT.SourceGenerator\Generator.RcwReflectionFallbackGenerator\RcwFallbackInitializer.g.cs
and
The type 'CoreWebView2HttpHeadersCollectionIterator' exists in both 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' and 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b' Cylch.Atp.Maui.App (net8.0-windows10.0.19041.0) \obj\Debug\net8.0-windows10.0.19041.0\win10-x64\intermediatexaml\WinRT.SourceGenerator\Generator.RcwReflectionFallbackGenerator\RcwFallbackInitializer.g.cs
Project 1 is a large MAUI project built with .Net 7 MAUI project templates and upgraded with every new release.
Project 2 is a smaller MAUI project built a few months ago with .Net 8 MAUI project templates.
Both projects tested return the same amount of errors (33). with the same errors.
Neither of these projects are intentionally using WebView2
components that we are aware of.
Both projects target:
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.0-windows10.0.19041.0</TargetFrameworks>
And platform:
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
Project 1 has to target Windows 10 to keep compatibility with our customer.
What I've tried to fix this from suggestions in other posts
Adding...
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<WindowsSdkPackageVersion>10.0.19041.38</WindowsSdkPackageVersion>
</PropertyGroup>
Does not resolve any of the errors.
Adding...
CsWinRTRcwFactoryFallbackGeneratorForceOptOut
Removes all errors and both projects compile and run.
However, I am now getting a debugging attachment error in Project 1 when running my Windows app that does not appear on machines that have not been upgraded to 17.11.5.
I cannot tell yet if this is an error related to the 17.11.5 update (did anything MAUI based get updated in 17.11.5?) or a new issue for us. I will spend more time on it tomorrow. iOS and Android work as expected, it only seems to be a Windows issue - break points still work but I've not been able to determine what line in our code is causing this. I will update as I debug.
Adding both WindowsSdkPackageVersion
and CsWinRTRcwFactoryFallbackGeneratorForceOptOut
only outputs unsafe
errors:
Unsafe code may only appear if compiling with /unsafe \obj\Debug\net8.0-windows10.0.19041.0\win10-x64\intermediatexaml\WinRT.SourceGenerator\Generator.WinRTAotSourceGenerator\WinRTGenericInstantiation.g.cs
When me and my team have some spare time, we'll try to rebuild a repo for testing.
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
8.0.91 SR9.1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.91 SR9.1
Affected platforms
Windows
Affected platform versions
net8.0-windows10.0.19041.0 / 10.0.17763.0
Did you find any workaround?
No response
Relevant log output
No response