Hello,
According to the development team's answer from There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'android-arm64 #17725, the Razor Class Library is not fully compatible with MAUI, which causes this issue.
As you discovered, Microsoft.AspNetCore.App cannot be used from within a .NET MAUI app (in most cases) because it requires features not supported in .NET MAUI. That also means that features such as @attribute [RenderModeServer] are not compatible with .NET MAUI because there is no such thing as "server rendering" in a .NET MAUI app. In general, the guidance is to place common cross-platform Razor Components in a Razor Class Library (RCL) project, and then each app project, such as .NET MAUI, ASP.NET, etc. can add anything it needs for specific platforms to be supported. So for the Index.razor file I would suggest putting most of the logic in some common IndexContent.razor file that doesn't specify @attribute [RenderModeServer], and then in the ASP.NET app's Index.razor you can specify the attribute and also render <IndexContent />. There are of course many other ways to do this, but the idea is the same: have platform-independent content in the RCL, and then each platform "customizes" it for the needs of each platform.
Based on the answers in How to use Razor Component Library with .Net MAUI #6194, you can encapsulate the required component to the MAUI class library and reference it.
What we currently recommend is that you put your Razor views, etc inside a Razor Class Library. And consume that from either a Maui Class Library or a Maui Application. If you need per-platform functionality, we recommend you define an interface for that functionality to use in Blazor and provide the implementations in a consuming Maui Class Library.
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.