Closed f4n0 closed 8 months ago
More context: The error is generated from my code:
public static Icon? ToFluentIcon(this Type icon)
{
return Activator.CreateInstance(icon) as Icon;
}
And helps me passing types instead of instances (I'm using attribute decorators)
By default, when you publish this type of project, Blazor deletes all parts of code not detected as "used". When using reflection, you must specify that this icon/code is used.
See https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options
I've also added
<PublishTrimmed>false</PublishTrimmed>
and
<TrimmerRootAssembly Include="Microsoft.FluentUI.AspNetCore.Components" />
<TrimmerRootAssembly Include="Microsoft.FluentUI.AspNetCore.Components.Icons" />
but it keeps failing
You say it fails on your (added) code. So you of need to add your own namespace as well
also added
and the ones that fails, is a "default" one
and referenced like this:
<FluentNavLink Href="@elem.Route" Match="NavLinkMatch.All" Icon="@(elem.Icon.ToFluentIcon())" IconColor="Color.Accent">@elem.Title</FluentNavLink>
Maybe you need to add something like this to your code:
[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(_{your type name}_))]
We are using Azure Static Web Apps for hosting the demo site ourselves and the icons etc are working there. See the demo client and demo shared projects here in the repo for the configuration we used. Closing this as it is not actionable from our side.
🐛 Bug Report
I've published a static web app, but I get this error:
💻 Repro or Code Sample
🤔 Expected Behavior
😯 Current Behavior
💁 Possible Solution
🔦 Context
🌍 Your Environment