Skip to content

Commit

Permalink
Merge pull request #216 from AArnott/fix215
Browse files Browse the repository at this point in the history
Workaround/fix for libgit2sharp custom marshal type cast failure
  • Loading branch information
AArnott authored Aug 25, 2018
2 parents dfd2c88 + 7bf53d5 commit f919d71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/MSBuildExtensionTask/ContextAwareTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ internal CustomAssemblyLoader(ContextAwareTask loaderTask)

protected override Assembly Load(AssemblyName assemblyName)
{
// Always load libgit2sharp in the default context.
// Something about the p/invoke done in that library with its custom marshaler
// doesn't sit well with Core CLR 2.x.
// See https://github.com/AArnott/Nerdbank.GitVersioning/issues/215 and https://github.com/dotnet/coreclr/issues/19654
AssemblyLoadContext preferredContext = assemblyName.Name.Equals("libgit2sharp", StringComparison.OrdinalIgnoreCase) ? Default : this;
string assemblyPath = Path.Combine(this.loaderTask.ManagedDllDirectory, assemblyName.Name) + ".dll";
if (File.Exists(assemblyPath))
{
return LoadFromAssemblyPath(assemblyPath);
return preferredContext.LoadFromAssemblyPath(assemblyPath);
}

return Default.LoadFromAssemblyName(assemblyName);
Expand Down
2 changes: 1 addition & 1 deletion src/Nerdbank.GitVersioning.Tasks/GetBuildVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ protected override bool ExecuteInner()
}
catch (ArgumentOutOfRangeException ex)
{
Log.LogErrorFromException(ex);
this.Log.LogErrorFromException(ex);
return false;
}
}
Expand Down

0 comments on commit f919d71

Please sign in to comment.