Razor SDK incompatible with iOS SDK regarding "Content" items
See original GitHub issueA Blazor Desktop with .NET MAUI project uses a combination of several .NET SDKs (in the “SDK-style project” sense). The iOS and Razor SDKs have a conflict where they disagree about how to process *.razor
files that are <Content ... />
items in the project. The Razor SDK converts those to <RazorComponent ... />
items so that the Razor compiler (source generator) can process them. The iOS SDK wants to include them along with <BundleResource ... />
items and include them in the generated PKG file.
Unfortunately the iOS targets seem to encounter a fatal error and in a “default” scenario with no workaround, you end up with MSBuild errors such as these:
Main.razor The path '../../../../../../../../src/Controls/samples/Controls.Sample/Main.razor' would result in a file outside of the app bundle and cannot be used.
[/Users/eilonlipton/Documents/GitHub/maui/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj]
Pages/Index.razor The path '../../../../../../../../src/Controls/samples/Controls.Sample/Pages/Index.razor' would result in a file outside of the app bundle and cannot be used.
[/Users/eilonlipton/Documents/GitHub/maui/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj]
_Imports.razor The path '../../../../../../../../src/Controls/samples/Controls.Sample/_Imports.razor' would result in a file outside of the app bundle and cannot be used.
[/Users/eilonlipton/Documents/GitHub/maui/src/Controls/samples/Controls.Sample/Maui.Controls.Sample-net6.csproj]
I’m not sure if this is a bug in the iOS targets or not, but regardless of that, we don’t want the iOS targets to try to bundle the *.razor
files as resources anyway.
So, we need to try to prevent the iOS SDK from even seeing these files as potential bundle resources and let the Razor SDK do its compilation.
One way to solve this is to include some build assets in the .NET MAUI BlazorWebView NuGet package that convert *.razor
files that are <Content ... />
items in the projectand convert them to <RazorComponent ... />
so that the iOS targets won’t see them at all, and the Razor SDK will compile them as intended.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Sounds like the same approach of having a custom metadata on Content items that tells us to not bundle those items in the app bundle would help here too.
I’m implementing support for the
PublishFolderType
onContent
(andBundleResource
) items for the next preview (14): https://github.com/xamarin/xamarin-macios/pull/14162.Set
PublishFolderType=None
to prevent these items from being copied to the app bundle.