[2.x] Warnings when `PublishAot` is enabled.
还没有人认领这个 Issue。
评估
调研方向
Start in Silk.NET.Core.Loader.DefaultPathResolver, where the warnings identify Assembly.Location, Assembly.CodeBase, and DependencyContext.Default usage. Reproduce with a small .NET 10 project using PublishAot=true and Vk.GetApi(), then trace the resolver paths that trigger the warnings. Done means AOT publishing no longer emits the reported warnings while native library loading continues to work.
由索引模型根据 Issue 内容生成。
描述
Summary
Silk.NET library loader generates warnings when AoT is enabled. Everything works at runtime with AOT, but warnings are reported and cannot be easily supressed.
Steps to reproduce
- Platform: Any (tested on Windows 11)
- Dotnet: v10.0.x
- Create a new dotnet project with
<PublishAot>true</PublishAot> - Add one single line:
using var vk = Vk.GetApi();. It fails with anyFoo.GetApi()call, not only with Vulkan. - You get the following warnings:
jhmci@CIBERMAN-PC MINGW64 /c/repos/open-source/silk-aot-repro
$ dotnet publish -c Release -r win-x64 -p:PublishAot=true
Restore complete (0.5s)
SilkAotRepro net10.0 win-x64 succeeded with 6 warning(s) (9.0s) → bin\Release\net10.0\win-x64\publish\
ILC : warning IL3000: Silk.NET.Core.Loader.DefaultPathResolver.<>c.<.cctor>b__24_3(String): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.<>c.<.cctor>b__24_3(String): Using member 'System.Reflection.Assembly.CodeBase.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. This member throws an exception for assemblies embedded in a single-file app.
ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetFromDeps(String,String&,String&): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.Default.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
ILC : warning IL3000: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetFromDeps(String,String&,String&): 'System.Reflection.Assembly.Location.get' always returns an empty string for assemblies embedded in a single-file app. If the path to the app directory is needed, consider calling 'System.AppContext.BaseDirectory'.
ILC : warning IL3002: Silk.NET.Core.Loader.DefaultPathResolver.TryLocateNativeAssetInRuntimesFolder(String,String,String&): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.Default.get' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
ILC : warning IL3002: Microsoft.Extensions.DependencyModel.DependencyContext..cctor(): Using member 'Microsoft.Extensions.DependencyModel.DependencyContext.LoadDefault()' which has 'RequiresAssemblyFilesAttribute' can break functionality when embedded in a single-file app. DependencyContext for an assembly from a application published as single-file is not supported. The method will return null. Make sure the calling code can handle this case.
Build succeeded with 6 warning(s) in 10.4s
Comments
Add any other context about the problem here.
If you know how to fix this issue, please submit a pull request instead!
- 主要语言
- C#
- 星标
- 5.3k
- 派生
- 484
- 平均合并
- 1 天 20 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/Silk.NET 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 76/100
-
难度 4/5 3-5 天 新手友好度 30/100
-
难度 3/5 半天 新手友好度 40/100
-
bug
难度 4/5 3-5 天 新手友好度 48/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 3 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
-
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
难度 2/5 1-3 小时 新手友好度 74/100
yksr-melt/Meltype#1346 · 2 条评论 ·
维护者通常 1 天内回复
-
Collect corrected translations in the app, with no GitHub account and the least possible friction未关闭localization medium ui
难度 2/5 1-3 小时 新手友好度 65/100
hexide-io/HexIDE#2819 · 1 条评论 ·
维护者通常 1 天内回复