cake-contrib / Cake_Git

Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp
https://cakebuild.net/extensions/cake-git
Other
39 stars 64 forks source link

Apple Silicon support #165

Open maludwig opened 2 years ago

maludwig commented 2 years ago

Hey friends,

So on OSX, on the new Apple Silicon chips (M1 / M2) etc, there is a bug that libgit2sharp fixed here:

https://github.com/libgit2/libgit2sharp/pull/1955/files

Discussion is here:

https://github.com/libgit2/libgit2sharp/pull/1955

I'm having trouble using Cake_Git on my M2 Macbook Air, and it seems like simply updating libgit2sharp would be sufficient to resolve the issue. But I'm not smart enough to figure this out on my own.

LibGit2Sharp 0.27.0-preview-0182 includes this change, so it should just be a matter of:

dotnet add package LibGit2Sharp --version 0.27.0-preview-0182

and then it's all fixed. Hopefullly.

I'm happy to help test fixes with my macbook.

devlead commented 2 years ago

Probably it's just a matter of changing these lines https://github.com/cake-contrib/Cake_Git/blob/fce1d5e4469f7caf718d79ebc53c49d6a5aac9ca/src/Cake.Git/Cake.Git.csproj#L21-L22

to

<PackageReference Include="LibGit2Sharp" Version="0.27.0-preview-0182" />
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.315" />

Would you like to take stab at creating a PR with the above changes?

maludwig commented 2 years ago

Happily.

maludwig commented 2 years ago

Hmm, just changing those two lines doesn't seem to make my tests pass. I'm getting this error and I don't understand what it means:


$ ./build.sh 
++ dirname ./build.sh
+ cd .
+ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
+ export DOTNET_CLI_TELEMETRY_OPTOUT=1
+ DOTNET_CLI_TELEMETRY_OPTOUT=1
+ export DOTNET_NOLOGO=1
+ DOTNET_NOLOGO=1
+ dotnet tool restore
Tool 'cake.tool' (version '2.0.0') was restored. Available commands: dotnet-cake

Restore was successful.
+ dotnet cake

----------------------------------------
Setup
----------------------------------------
Building Release version 2.0.0 of Cake.Git (2.0.0), IsMainBranch: False, Publish: False.

========================================
Clean
========================================
Cleaning /Users/mitchellludwig/dev/Cake_Git/src
Cleaning /Users/mitchellludwig/dev/Cake_Git/nuget
Cleaning /Users/mitchellludwig/dev/Cake_Git/artifacts

========================================
Restore
========================================
Restoring /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git.sln...
  Determining projects to restore...
  Restored /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj (in 87 ms).

========================================
SolutionInfo
========================================

========================================
Build
========================================
Building /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git.sln
MSBuild version 17.3.0+92e077650 for .NET
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Release/net6.0/Cake.Git.dll
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Release/net5.0/Cake.Git.dll
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Release/netcoreapp3.1/Cake.Git.dll

Build succeeded.

/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
    15 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.61

========================================
Publish-Artifacts
========================================
MSBuild version 17.3.0+92e077650 for .NET
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Debug/netcoreapp3.1/Cake.Git.dll
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/artifacts/netcoreapp3.1/
MSBuild version 17.3.0+92e077650 for .NET
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Debug/net5.0/Cake.Git.dll
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/artifacts/net5.0/
MSBuild version 17.3.0+92e077650 for .NET
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(136,36): warning CS3003: Type of 'GitFetchSettings.RefSpecFilter' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Fetch.cs(142,30): warning CS3003: Type of 'GitFetchSettings.TagFetchMode' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitBranch.cs(51,37): warning CS3001: Argument type 'Repository' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(27,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/GitAliases.Tags.cs(55,33): warning CS3002: Return type of 'GitAliases.GitTags(ICakeContext, DirectoryPath, bool)' is not CLS-compliant [/Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/Cake.Git.csproj]
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/src/Cake.Git/bin/Debug/net6.0/Cake.Git.dll
  Cake.Git -> /Users/mitchellludwig/dev/Cake_Git/artifacts/net6.0/

========================================
Create-NuGet-Package
========================================
Attempting to build package from 'Cake.Git.temp.nuspec'.
Successfully created package '/Users/mitchellludwig/dev/Cake_Git/nuget/Cake.Git.2.0.0.nupkg'.

========================================
Test
========================================
Testing netcoreapp3.1

----------------------------------------
Setup
----------------------------------------
Running tasks...
Testing version 2.0.0 of Cake Git Addin (2.0.0).

========================================
Clean
========================================

========================================
Git-Init
========================================
Creating repository...
An error occurred when executing task 'Git-Init'.

----------------------------------------
Teardown
----------------------------------------
Finished running tasks.
Trying to clean up test repo /Users/mitchellludwig/dev/Cake_Git/TestRepo
Successfully cleaned test repo /Users/mitchellludwig/dev/Cake_Git/TestRepo
Error: One or more errors occurred. (The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.)
    The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception.
An error occurred when executing task 'Test'.

----------------------------------------
Teardown
----------------------------------------
Finished running tasks.
Error: One or more errors occurred. (.NET CLI: Process returned an error (exit code 1).)
    .NET CLI: Process returned an error (exit code 1).
devlead commented 2 years ago

Could you create a draft PR? So we can see if it fails on CI too? Might be that we need to add some runtime folders.

Worst case we'll need upcoming Cake 2.3 as it will have native library improvements.

maludwig commented 2 years ago

Here you go, I think you need to manually run the CI for me.

maludwig commented 2 years ago

Yep OSX CI is also dying. Same error. Any ideas?

pascalberger commented 7 months ago

Version 4 introduced a separate addin for Cake Frosting (Cake.Frosting.Git) which references LibGit2Sharp instead of repackaging it and therefore should also work with Silicon chips.

We should keep this issue open to track progress for Cake Scripting using Cake.Git addin.