Skip to content

[pull] master from microsoft:master#99

Merged
pull[bot] merged 3 commits into
cgallred:masterfrom
microsoft:master
May 15, 2026
Merged

[pull] master from microsoft:master#99
pull[bot] merged 3 commits into
cgallred:masterfrom
microsoft:master

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented May 15, 2026

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 : )

tyrielv added 3 commits May 12, 2026 13:37
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
@pull pull Bot locked and limited conversation to collaborators May 15, 2026
@pull pull Bot added the ⤵️ pull label May 15, 2026
@pull pull Bot merged commit e4d1f83 into cgallred:master May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant