libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

Repository.Clone fails on .NET Framework with "Operation is not supported on this platform"

Open augustoproiete opened this issue 2 years ago • 0 comments

Originally discovered and reported by @savornicesei in the Cake.Git project.


Reproduction steps

  • Create a Console app targeting .NET Framework 4.6.1
  • Add the NuGet packages below to the project
    • LibGit2Sharp v0.27.0-preview-0102
    • LibGit2Sharp.NativeBinaries v2.0.312
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="LibGit2Sharp" Version="0.27.0-preview-0102" />
    <PackageReference Include="LibGit2Sharp.NativeBinaries" Version="2.0.312" />
  </ItemGroup>

</Project>
  • Attempt to clone a Git repository:
var sourceUrl = "https://github.com/WCOMAB/CakeGitTestRepo.git";
var workdirPath = @"C:\augustoproiete\CakeGitTestRepo";

Directory.CreateDirectory(workdirPath);

Repository.Clone(sourceUrl, workdirPath);

Expected behavior

Repository cloned successfully.

Actual behavior

Unhandled Exception: LibGit2Sharp.LibGit2SharpException: The type initializer for 'ManagedHttpSmartSubtransportStream' threw an exception.

Inner Exception:
    Operation is not supported on this platform.
   at LibGit2Sharp.Core.Ensure.HandleError(Int32 result)
   at LibGit2Sharp.Core.Proxy.git_clone(String url, String workdir, GitCloneOptions& opts)
   at LibGit2Sharp.Repository.Clone(String sourceUrl, String workdirPath, CloneOptions options)
   at ReproCake_Git_151.Program.Main(String[] args)

image

Version of LibGit2Sharp (release number or SHA1)

  • LibGit2Sharp v0.27.0-preview-0102
  • LibGit2Sharp.NativeBinaries v2.0.312

Operating system(s) tested; .NET runtime tested

  • Windows 10 Pro (10.0.19042)
  • .NET Framework 4.8 (4.8.04084)
  • Visual Studio 2019 (16.11.1)

augustoproiete avatar Aug 19 '21 23:08 augustoproiete