[pull] master from microsoft:master#99
Merged
Merged
Conversation
Replace the LibGit2Sharp.NativeBinaries NuGet package (which shipped a
dynamic git2-*.dll) with a vcpkg-built static git2.lib that the NativeAOT
linker embeds directly into the executable. This eliminates libgit2
DLL-missing crashes we see in telemetry.
A side benefit of this approach is that we can apply patches to libgit2
that haven't been included in an official release yet, via the vcpkg
overlay port in overlays/libgit2/.
How it works:
- vcpkg manifest (vcpkg.json) declares libgit2 as a dependency
- Custom triplet (x64-windows-static-aot) builds with static CRT and
library linkage, producing git2.lib instead of git2.dll
- Overlay port (overlays/libgit2/) pins libgit2 v1.9.3 and can carry
patches ahead of upstream releases
- Directory.Build.props wires <DirectPInvoke> and <NativeLibrary>
items so the NativeAOT linker resolves P/Invoke calls at link time
and embeds git2 + transitive deps (pcre, zlib, http-parser)
To rebuild vcpkg libs locally:
vcpkg install --triplet x64-windows-static-aot \
--overlay-triplets=triplets --overlay-ports=overlays
Changes:
- Directory.Build.props: DirectPInvoke + NativeLibrary for AOT link,
unconditional libgit2_filename=git2 (was git2-a418d9d from NuGet)
- Directory.Packages.props: remove LibGit2Sharp.NativeBinaries
- GVFS.Common.csproj, GVFS.Hooks.csproj: remove NuGet package ref
- Readme.md: reference THIRD-PARTY-NOTICES.md from license section
- THIRD-PARTY-NOTICES.md: document libgit2 (GPLv2 + linking exception),
SQLite (public domain), SQLitePCLRaw (Apache 2.0)
- vcpkg.json, vcpkg-configuration.json: vcpkg manifest + baseline
- triplets/x64-windows-static-aot.cmake: static linkage triplet
- overlays/libgit2/: port overlay (v1.9.3) from devprod.razzletools
- .gitignore: exclude vcpkg_installed/
License: libgit2's COPYING includes an explicit linking exception that
permits static linking without imposing GPL on the consuming program.
Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Build script improvements: - Add vcpkg install to Build.bat with vswhere-based vcpkg discovery - Add _RestoreVcpkgDependencies MSBuild target (modeled after official vcpkg VcpkgInstallManifestDependencies) that auto-runs vcpkg install on first VS/dotnet build — uses stamp file for incrementality - Scope vcpkg restore target to GVFS.Common to avoid parallel conflicts - Move vcpkg output from src/vcpkg_installed/ to out/vcpkg_installed/ - Declare overlay-ports and overlay-triplets in vcpkg-configuration.json - Restore explicit CI vcpkg step using preinstalled VCPKG_INSTALLATION_ROOT - Exclude GVFS.MSBuild from libgit2 Content items (IncludeBuildOutput=false) - Remove vcpkg_installed/ from .gitignore (no longer in git root) Code fix: - Update giterr_last P/Invoke to git_error_last (deprecated since libgit2 0.28) Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Statically link libgit2 into NativeAOT executables via vcpkg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )