-
Notifications
You must be signed in to change notification settings - Fork 332
Description
Hello,
It would be great if ImGui.NET provided optional support for NativeAOT-friendly builds, by including a small .targets file that allows static linking of the cimgui native library during Native AOT compilation.
According to Microsoft documentation on Native code interop with Native AOT, the and MSBuild items can be used to enable direct static linking of native libraries into AOT-compiled applications:
<ItemGroup>
<DirectPInvoke Include="cimgui" />
<NativeLibrary Include="cimgui.lib" Condition="$(RuntimeIdentifier.StartsWith('win'))" />
<NativeLibrary Include="libcimgui.a" Condition="!$(RuntimeIdentifier.StartsWith('win'))" />
</ItemGroup>
This is especially useful for internal tooling and menu overlays compiled into standalone native DLLs with ILCompiler (NativeAOT), where zero dependencies are desired and dynamic loading is discouraged or unavailable (e.g. in injected code or sandboxed environments).
A minimal .targets file that adds the static .lib/.a based on the RID would be enough. NuGet package consumers could opt-in to static linking when targeting NativeAOT.
Would you consider adding this?
Thanks!