When using the Cake.Git addin on macOS (arm64), the required native binary libgit2-a2bde63.dylib fails to load. The addin attempts to load a binary from the default location (tools/Addins/Cake.Git.4.0.0/lib/net8.0/) that is built for the x64 architecture, which is incompatible with macOS arm64.
However, a compatible binary is included in the package at tools/Addins/Cake.Git.4.0.0/runtimes/osx-arm64/native/libgit2-a2bde63.dylib. Manually replacing the default binary with the binary provided in the "runtimes" directory resolves the issue.
The Cake should automatically detect and load the appropriate native binary for the target runtime and architecture at least for Cake.Git. On macOS arm64, it should load the binary from runtimes/osx-arm64/native/libgit2-a2bde63.dylib instead of using the incompatible x64 binary from lib/net8.0/.
Error: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'git2-a2bde63' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable:
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63.dylib' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63.dylib' (no such file)
dlopen(git2-a2bde63.dylib, 0x0001): tried: 'git2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSgit2-a2bde63.dylib' (no such file), '/usr/lib/git2-a2bde63.dylib' (no such file, not in dyld cache), 'git2-a2bde63.dylib' (no such file), '/usr/local/lib/git2-a2bde63.dylib' (no such file), '/usr/lib/git2-a2bde63.dylib' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63.dylib' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
dlopen(libgit2-a2bde63.dylib, 0x0001): tried: 'libgit2-a2bde63.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgit2-a2bde63.dylib' (no such file), '/usr/lib/libgit2-a2bde63.dylib' (no such file, not in dyld cache), 'libgit2-a2bde63.dylib' (no such file), '/usr/local/lib/libgit2-a2bde63.dylib' (no such file), '/usr/lib/libgit2-a2bde63.dylib' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/git2-a2bde63' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/git2-a2bde63' (no such file)
dlopen(git2-a2bde63, 0x0001): tried: 'git2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OSgit2-a2bde63' (no such file), '/usr/lib/git2-a2bde63' (no such file, not in dyld cache), 'git2-a2bde63' (no such file), '/usr/local/lib/git2-a2bde63' (no such file), '/usr/lib/git2-a2bde63' (no such file, not in dyld cache)
dlopen(/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63, 0x0001): tried: '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file), '/usr/local/share/dotnet/shared/Microsoft.NETCore.App/9.0.0/libgit2-a2bde63' (no such file)
dlopen(/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63, 0x0001): tried: '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file), '/Users/**/service_repo/cake/tools/Addins/Cake.Git.4.0.0/lib/net8.0/libgit2-a2bde63' (no such file)
dlopen(libgit2-a2bde63, 0x0001): tried: 'libgit2-a2bde63' (no such file), '/System/Volumes/Preboot/Cryptexes/OSlibgit2-a2bde63' (no such file), '/usr/lib/libgit2-a2bde63' (no such file, not in dyld cache), 'libgit2-a2bde63' (no such file), '/usr/local/lib/libgit2-a2bde63' (no such file), '/usr/lib/libgit2-a2bde63' (no such file, not in dyld cache)
Prerequisites
Cake runner
Cake .NET Tool
Cake version
All
Operating system
macOS
Operating system architecture
Arm64
CI Server
No response
What are you seeing?
When using the Cake.Git addin on macOS (arm64), the required native binary libgit2-a2bde63.dylib fails to load. The addin attempts to load a binary from the default location (tools/Addins/Cake.Git.4.0.0/lib/net8.0/) that is built for the x64 architecture, which is incompatible with macOS arm64.
However, a compatible binary is included in the package at tools/Addins/Cake.Git.4.0.0/runtimes/osx-arm64/native/libgit2-a2bde63.dylib. Manually replacing the default binary with the binary provided in the "runtimes" directory resolves the issue.
What is expected?
The Cake should automatically detect and load the appropriate native binary for the target runtime and architecture at least for Cake.Git. On macOS arm64, it should load the binary from runtimes/osx-arm64/native/libgit2-a2bde63.dylib instead of using the incompatible x64 binary from lib/net8.0/.
Steps to Reproduce
Optional:
Output log