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 63 forks source link

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

Open savornicesei opened 3 years ago

savornicesei commented 3 years ago

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

augustoproiete commented 3 years ago

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

image

savornicesei commented 3 years ago

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.

augustoproiete commented 3 years ago

@savornicesei Indeed the problem is internal to libgit2sharp and will need to be fixed there. Tracking via https://github.com/libgit2/libgit2sharp/issues/1904

SergeiTerentev commented 3 years ago

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

augustoproiete commented 3 years ago

@SergeiTerentev Could be... The libgit2sharp team might know more details -> https://github.com/libgit2/libgit2sharp/issues/1904

SergeiTerentev commented 3 years ago

Here is workaround:

addin nuget:?package=Cake.Git&version=1.0.1

It use previous version of libgit2sharp and has no issue

devlead commented 3 years ago

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
devlead commented 3 years ago

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

Imperatorn commented 2 years ago

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

pascalberger commented 8 months ago

https://github.com/libgit2/libgit2sharp/issues/1904 has been closed as fixed in LibGit2Sharp 0.29.0

Created https://github.com/cake-contrib/Cake_Git/issues/176 to track update of Cake.Git to LibGit2Sharp 0.29.0