maui: XAMLC error when building an app with AoT compilation
Description
When building an app using AoT in release mode it breaks during build with the error message:
C:\Users\userName.nuget\packages\microsoft.maui.controls.build.tasks\9.0.10\buildTransitive\netstandard2.0\Microsoft.Maui.Controls.targets(171,3): Member ‘System.IComparable’ is declared in another module and needs to be imported [\MCT\samples\CommunityToolkit.Maui.Sample\CommunityToolkit.Maui.Sample.csproj]
Steps to Reproduce
- Run the sample project on the toolkit repo (be sure to that you’re on
feature/sl-dotnet-ninebranch - open the terminal and go to
\samples\CommunityToolkit.Maui.Sample - run, on terminal,
dotnet build -c Release -bl - See the message error
Binlog: msbuild.zip
Link to public reproduction project repository
https://github.com/CommunityToolkit/Maui/tree/feature/sl-dotnet-nine
Version with bug
9.0.10 SR1
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.100 SR10
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
All versions
Did you find any workaround?
N/A
Relevant log output
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (7 by maintainers)
Commits related to this issue
- Fix XAMLC error when building an app with AoT compilation Fixes #25871 Fix the XAMLC error when building an app with AoT compilation. * Add `CompareConverter` class in `src/CommunityToolkit.Maui/Co... — committed to TheCodeTraveler/maui by TheCodeTraveler 2 years ago
- [XC] import types in StaticResourceExtensions - fixes #25871 — committed to dotnet/maui by StephaneDelcroix 2 years ago
- [XC] import types in StaticResourceExtensions (#26303) - fixes #25871 — committed to anandhan-rajagopal/maui by StephaneDelcroix 2 years ago
Look like this bug is blocking CommunityToolkit new release. Hope you’ll find a way to fix that ! ❤️
I have performed some investigations this morning and I believe I can pinpoint the specific usage that is causing this. We see the error being reported from this line
https://github.com/CommunityToolkit/Maui/blob/e46c39e5f311df772edcdeb235f64c605160ed3e/samples/CommunityToolkit.Maui.Sample/Views/Popups/UpdatingPopup.xaml#L44
If I comment the above line out then the project will compile. Note that this inside a Popup.
Furthermore if I take that same binding and place it in here https://github.com/CommunityToolkit/Maui/blob/main/samples/CommunityToolkit.Maui.Sample/Pages/Converters/CompareConverterPage.xaml changing the property to
SliderValueand the namespace tomctthen the code will happily compile. Note that this inside a ContentPage.I suspect that the XAMLC is somehow not performing the same tasks for our
PopupXAML that it is forContentPageXAML.In case it helps for the context of finding the issue I can workaround the problem by creating a subclass of our
CompareConvertere.g.and then using this in the UpdatingPopup.xaml file.
@jonathanpeppers @StephaneDelcroix @PureWeen Guys please tell us whether we should wait or kiss .NET 9 goodbye and wait for .NET 10 to be able to make an decent update. No word so far to when this is going to be fixed? As you can see this bug is now officially blocking updating most of the MAUI apps out there.
I also hope that. It’s blocking my release and my migration to .NET 9.0 as well 😕
Any word from the MAUI team in regards to when this will finally happen would be nice for us poor developers 😃
Oh great thanks. Perhaps I will see if I can reproduce the issue under test and then it would help to prove the fix is right 👍
thanks for the investigation. could you please provide a really simple sample that doesn’t depend on the toolkit, so we can generate a unit test, investigate, fix the issue, and make sure it doesn’t regress ? thanks
This seems unrelated to AOT, the
<XamlCTask/>is failing to write an assembly,Mono.Cecilis giving this error:If you use
System.IComparablein your assembly somewhere, does it fix it? I think you could literally just make a method that isn’t called?