You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enable static linking of libgit2 (NativeLibrary / DirectPInvoke) for NativeAOT builds #2160
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).
Activity
PDWhittington commentedon Jun 30, 2026
Would you be prepared to assign me this issue?
I am writing a .Net tool that I want to be AOT-compiled and which consumes LibGit2Sharp.
To begin with I am going to be testing it on the Mac, but I have Windows and Linux systems too, so I will be able to test it on those also.
I am aiming to attempt this work locally this week and if I'm successful then I would like to push up some changes for review by the maintainers.
MEANWHILE -- Thanks so much for everything you've done. This libgit wrapper is really nice to work with.