Closed shatyuka closed 2 months ago
我的最小化 demo 在 AOT 下起不来,也看不到 stack trace
是资源文件被错误剪裁掉了吗?建议可以用 HxD 之类的工具看看生成的 exe 有没有正确包括两个 ttf 文件
确认了字体文件是有打包进exe的。 而且在xaml里指定Segoe字体是可以运行的:
<StackPanel>
<ic:SymbolIcon Symbol="Home" />
<ic:SymbolIcon Symbol="Home" UseSegoeMetrics="True"/>
</StackPanel>
在 BuildAvaloniaApp
里调用 UseSegoeMetrics()
就会崩溃
AOT 要加些啥东西,怎么查 trace?我这边 demo 起不来。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<TrimMode>copyused</TrimMode>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<PublishAot>true</PublishAot>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.*" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.*" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.*" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.*" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.*" />
<PackageReference Include="FluentIcons.Avalonia" Version="1.1.*" />
<!-- <PackageReference Include="SkiaSharp" Version="3.0.0-preview.0.132" /> -->
</ItemGroup>
<ItemGroup>
<TrimmerRootDescriptor Include=".\TrimmerRoots.xml" />
</ItemGroup>
</Project>
<linker>
<!-- App -->
<assembly fullname="AvaloniaDemo" preserve="All" />
<!-- Avalonia Themes -->
<assembly fullname="Avalonia.Themes.Fluent" preserve="All" />
</linker>
csproj里加<PublishAot>true</PublishAot>
我用Rider直接运行就可以看到崩溃堆栈
上游 bug。参见链接 issue。 Upstream bug. See linked isssue.
Avalonia 11.0.10 FluentIcons.Avalonia 1.1.234 Crash on both macOS and Windows with
UseSegoeMetrics()
and NativeAOT on.