cake-contrib / Cake_Git

Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp

Home Page:https://cakebuild.net/extensions/cake-git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clone test - The type initializer for 'ManagedHttpSmartSubtransportStream' threw an exception

savornicesei opened this issue · comments

Hi,

I'm just running the build script on develop branch, on W10 `.\build.ps1' and I get this error on the Clone test:

========================================
Git-Clone
========================================
Cloning repo https://github.com/WCOMAB/CakeGitTestRepo.git...
An error occurred when executing task 'Git-Clone'.

----------------------------------------
Teardown
----------------------------------------
Finished running tasks.
Trying to clean up test repo D:/OSS/cake-build/upstream-Cake_Git/TestRepo
Successfully cleaned test repo D:/OSS/cake-build/upstream-Cake_Git/TestRepo
Error: One or more errors occurred.
        The type initializer for 'ManagedHttpSmartSubtransportStream' threw an exception.

Inner Exception:
    Operation is not supported on this platform.
An error occurred when executing task 'Test'.

Is there some setup required for succesfully run the net461 tests?

Thanks,
Simo

I can repro on a Windows 10 VM with .NET Framework 4.8 installed:

image

Thanks for confirmation.
I tried with the latest libgit2sharp but got the same error. One thing that I noticed is that libgit2sharp targets only netstandard2.0;netcoreapp2.1 but netstandard2.0 should be compatible with .net461.

@savornicesei Indeed the problem is internal to libgit2sharp and will need to be fixed there. Tracking via libgit2/libgit2sharp#1904

Hi, I have faced with same error, what has broken? windows update?

@SergeiTerentev Could be... The libgit2sharp team might know more details -> libgit2/libgit2sharp#1904

Here is workaround:
#addin nuget:?package=Cake.Git&version=1.0.1
It use previous version of libgit2sharp and has no issue

Here is workaround:
#addin nuget:?package=Cake.Git&version=1.0.1
It use previous version of libgit2sharp and has no issue

Interesting previous versions don't work with newer Linux distributions and MacOS versions.

Guess the workaround could then be to pin the version with an environment variable until it's fixed upstream i.e.

#addin nuget:?package=Cake.Git&%CAKE_GIT_VERSION_OVERRIDE%

var testCloneRepo           = MakeAbsolute(Directory("./TestRepo/CloneRepo"));
var sourceUrl = "https://github.com/WCOMAB/CakeGitTestRepo.git";


if (DirectoryExists(testCloneRepo))
{
    DeleteDirectory(
        testCloneRepo,
        new DeleteDirectorySettings {
            Recursive = true,
            Force = true
        }
    );
}

Information("Cloning repo {0}...", sourceUrl);
var repo = GitClone(sourceUrl, testCloneRepo);
Information("Cloned {0}.", repo);

And then it can be overridden by an env variable like this

$ENV:CAKE_GIT_VERSION_OVERRIDE="version=1.01"
dotnet cake .\cakegit.cake

But if previous versions work it's even more clear it's an upstream issue.

Here is workaround:
#addin nuget:?package=Cake.Git&version=1.0.1
It use previous version of libgit2sharp and has no issue

This worked for me. You just saved my life

libgit2/libgit2sharp#1904 has been closed as fixed in LibGit2Sharp 0.29.0

Created #176 to track update of Cake.Git to LibGit2Sharp 0.29.0