Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[2.x] Warnings when `PublishAot` is enabled.

未关闭
#2,633 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
csharp
领域
backend, devtools

调研方向

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 内容生成。

描述

bug

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
  1. Create a new dotnet project with <PublishAot>true</PublishAot>
  2. Add one single line: using var vk = Vk.GetApi();. It fails with any Foo.GetApi() call, not only with Vulkan.
  3. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

dotnet/Silk.NET 的其他 Issue

查看 dotnet/Silk.NET 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。