libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.19k stars 888 forks source link

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

Closed augustoproiete closed 11 months ago

augustoproiete commented 3 years ago

_Originally discovered and reported by @savornicesei in the Cake.Git project_.


Reproduction steps

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

Operating system(s) tested; .NET runtime tested

bording commented 11 months ago

This should be fixed in the latest releases.