libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Enable static linking of libgit2 (NativeLibrary / DirectPInvoke) for NativeAOT builds

Open harayuu9 opened this issue 5 months ago • 0 comments

Overview Publishing with dotnet publish -p:PublishAot=true (NativeAOT) currently leaves the libgit2 native DLL/so/dylib in the output folder, preventing a true single-file distribution. If LibGit2Sharp exposed NativeLibrary / DirectPInvoke metadata to let the linker embed a static libgit2, NativeAOT users could ship just one executable.

Problems

  • NativeAOT disables the single-file bundler, so IncludeNativeLibrariesForSelfExtract is ignored and the native library is always emitted next to the .exe.
  • Distributors must ship extra files, and there is no self-extract logic at runtime.

Request Please add official support for statically linking libgit2 when LibGit2Sharp is used with NativeAOT (for example, by publishing a package that injects the required NativeLibrary metadata).

Reference

harayuu9 avatar Jul 14 '25 13:07 harayuu9