Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LibGit2Sharp update to 0.26.0 #1659

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 21 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,25 @@ Task("Copy-Files")
MSBuildSettings = parameters.MSBuildSettings
});

DotNetCorePublish("./src/GitVersion.MsBuild/GitVersion.MsBuild.csproj", new DotNetCorePublishSettings
{
Framework = parameters.FullFxVersion,
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration,
MSBuildSettings = parameters.MSBuildSettings
});

// .NET Core
DotNetCorePublish("./src/GitVersion.MsBuild/GitVersion.MsBuild.csproj", new DotNetCorePublishSettings
{
Framework = parameters.CoreFxVersion,
NoBuild = true,
NoRestore = true,
Configuration = parameters.Configuration,
MSBuildSettings = parameters.MSBuildSettings
});

var ilMergeDir = parameters.Paths.Directories.ArtifactsBinFullFxILMerge;
var portableDir = parameters.Paths.Directories.ArtifactsBinFullFxPortable.Combine("tools");
var cmdlineDir = parameters.Paths.Directories.ArtifactsBinFullFxCmdline.Combine("tools");
Expand Down Expand Up @@ -357,9 +376,9 @@ Task("Pack-Nuget")
MSBuildSettings = parameters.MSBuildSettings
};

// GitVersionCore, GitVersionTask, & global tool
// GitVersionCore, GitVersion.MsBuild, & global tool
DotNetCorePack("./src/GitVersionCore", settings);
DotNetCorePack("./src/GitVersionTask", settings);
DotNetCorePack("./src/GitVersion.MsBuild", settings);
DotNetCorePack("./src/GitVersionExe/GitVersion.Tool.csproj", settings);
});

Expand Down
5 changes: 2 additions & 3 deletions build/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class BuildParameters
Packages = BuildPackages.GetPackages(
Paths.Directories.NugetRoot,
Version.SemVersion,
new [] { "GitVersion.CommandLine.DotNetCore", "GitVersion.CommandLine", "GitVersionCore", "GitVersionTask", "GitVersion.Tool" },
new [] { "GitVersion.CommandLine.DotNetCore", "GitVersion.CommandLine", "GitVersionCore", "GitVersion.MsBuild", "GitVersion.Tool" },
new [] { "GitVersion.Portable" });

var files = Paths.Files;
Expand All @@ -116,8 +116,7 @@ public class BuildParameters
{
["GitVersion.CommandLine.DotNetCore"] = Paths.Directories.ArtifactsBinCoreFx,
["GitVersion.CommandLine"] = Paths.Directories.ArtifactsBinFullFxCmdline,
["GitVersion.Portable"] = Paths.Directories.ArtifactsBinFullFxPortable,
["GitVersion.Tool"] = Paths.Directories.ArtifactsBinCoreFx,
["GitVersion.Portable"] = Paths.Directories.ArtifactsBinFullFxPortable
};

Credentials = BuildCredentials.GetCredentials(context);
Expand Down
3 changes: 1 addition & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@

</PropertyGroup>
<PropertyGroup>
<PackageVersion_LibGit2Sharp>0.25.0-preview-0033</PackageVersion_LibGit2Sharp>
<PackageVersion_LibGit2SharpNativeBinaries>[1.0.185]</PackageVersion_LibGit2SharpNativeBinaries>
<PackageVersion_LibGit2Sharp>0.26.0</PackageVersion_LibGit2Sharp>
<PackageVersion_JetBrainsAnnotations>2019.1.1</PackageVersion_JetBrainsAnnotations>
<PackageVersion_YamlDotNet>6.0.0</PackageVersion_YamlDotNet>
</PropertyGroup>
Expand Down
4 changes: 0 additions & 4 deletions src/Docker/net472/linux/debian-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ FROM mono:5.14
LABEL maintainers="GitTools Maintainers"
ARG contentFolder

RUN sed -i '/jessie-updates/d' /etc/apt/sources.list && apt-get update && \
apt-get install -y libgit2-dev && \
ln -s /usr/lib/x86_64-linux-gnu/libgit2.so /lib/x86_64-linux-gnu/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

Expand Down
8 changes: 3 additions & 5 deletions src/Docker/netcoreapp2.1/linux/centos-7/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
FROM centos:7
LABEL maintainers="GitTools Maintainers"

ENV DOTNET_VERSION='2.1'
ENV DOTNET_VERSION='2.1'
ARG contentFolder

# https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-current
RUN rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm \
&& yum update cache

# if you need SDK use dotnet-sdk-$DOTNET_VERSION
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 unzip libgit2-devel.x86_64 \
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 \
&& yum clean all \
&& rm -rf /tmp/*

RUN ln -s /usr/lib64/libgit2.so /usr/lib64/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

ENTRYPOINT ["dotnet", "GitVersion.dll"]
ENTRYPOINT ["dotnet", "GitVersion.dll"]
4 changes: 0 additions & 4 deletions src/Docker/netcoreapp2.1/linux/debian-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ FROM mcr.microsoft.com/dotnet/core/runtime:2.1
LABEL maintainers="GitTools Maintainers"
ARG contentFolder

RUN apt-get update && \
apt-get install -y libgit2-dev && \
ln -s /usr/lib/x86_64-linux-gnu/libgit2.so /lib/x86_64-linux-gnu/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

Expand Down
10 changes: 4 additions & 6 deletions src/Docker/netcoreapp2.1/linux/fedora-27/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
FROM fedora:27
LABEL maintainers="GitTools Maintainers"

ENV DOTNET_VERSION='2.1'
ENV DOTNET_VERSION='2.1'
ARG contentFolder

# https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-current
RUN rpm -Uvh https://packages.microsoft.com/config/fedora/27/packages-microsoft-prod.rpm
RUN rpm -Uvh https://packages.microsoft.com/config/fedora/27/packages-microsoft-prod.rpm

# if you need SDK use dotnet-sdk-$DOTNET_VERSION
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 unzip libgit2-devel.x86_64 \
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64\
&& yum clean all \
&& rm -rf /tmp/*

RUN ln -s /usr/lib64/libgit2.so /usr/lib64/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

ENTRYPOINT ["dotnet", "GitVersion.dll"]
ENTRYPOINT ["dotnet", "GitVersion.dll"]
4 changes: 1 addition & 3 deletions src/Docker/netcoreapp2.2/linux/centos-7/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ RUN rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-pro
&& yum update cache

# if you need SDK use dotnet-sdk-$DOTNET_VERSION
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 unzip libgit2-devel.x86_64 \
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 \
&& yum clean all \
&& rm -rf /tmp/*

RUN ln -s /usr/lib64/libgit2.so /usr/lib64/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

Expand Down
4 changes: 0 additions & 4 deletions src/Docker/netcoreapp2.2/linux/debian-9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ FROM mcr.microsoft.com/dotnet/core/runtime:2.2
LABEL maintainers="GitTools Maintainers"
ARG contentFolder

RUN apt-get update && \
apt-get install -y libgit2-dev && \
ln -s /usr/lib/x86_64-linux-gnu/libgit2.so /lib/x86_64-linux-gnu/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

Expand Down
6 changes: 2 additions & 4 deletions src/Docker/netcoreapp2.2/linux/fedora-27/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@ ENV DOTNET_VERSION='2.2'
ARG contentFolder

# https://dotnet.microsoft.com/download/linux-package-manager/rhel/sdk-current
RUN rpm -Uvh https://packages.microsoft.com/config/fedora/27/packages-microsoft-prod.rpm
RUN rpm -Uvh https://packages.microsoft.com/config/fedora/27/packages-microsoft-prod.rpm

# if you need SDK use dotnet-sdk-$DOTNET_VERSION
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 unzip libgit2-devel.x86_64 \
RUN yum install -y dotnet-runtime-$DOTNET_VERSION.x86_64 \
&& yum clean all \
&& rm -rf /tmp/*

RUN ln -s /usr/lib64/libgit2.so /usr/lib64/libgit2-15e1193.so

WORKDIR /app
COPY $contentFolder/ ./

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using GitVersion;
using GitVersion.MsBuild.Task;
using GitVersionTask;
using Microsoft.Build.Framework;
using NUnit.Framework;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<Content Include="Approved\**\*.txt" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GitVersionTask\GitVersionTask.csproj" />
<ProjectReference Include="..\GitVersion.MsBuild\GitVersion.MsBuild.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.IO;
using GitVersion;
using GitVersion.MsBuild;
using GitVersionTask.Tests.Mocks;
using Microsoft.Build.Framework;
using NUnit.Framework;
Expand Down
21 changes: 21 additions & 0 deletions src/GitVersion.MsBuild.Task/GenerateGitVersionInformation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace GitVersion.MsBuild.Task
{
using Microsoft.Build.Framework;

public class GenerateGitVersionInformation : GitVersionTaskBase
{
[Required]
public string ProjectFile { get; set; }

[Required]
public string IntermediateOutputPath { get; set; }

[Required]
public string Language { get; set; }

[Output]
public string GitVersionInformationFilePath { get; set; }

public override bool Execute() => TaskProxy.GenerateGitVersionInformation(this);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GitVersionTask
namespace GitVersion.MsBuild.Task
{
using Microsoft.Build.Framework;

Expand Down Expand Up @@ -94,15 +94,6 @@ public class GetVersion : GitVersionTaskBase
[Output]
public string CommitsSinceVersionSourcePadded { get; set; }

protected override void InnerExecute()
{
if (GetVersionVariables(out var versionVariables)) return;

var thisType = typeof(GetVersion);
foreach (var variable in versionVariables)
{
thisType.GetProperty(variable.Key)?.SetValue(this, variable.Value, null);
}
}
public override bool Execute() => TaskProxy.GetVersion(this);
}
}
21 changes: 21 additions & 0 deletions src/GitVersion.MsBuild.Task/GitVersion.MsBuild.Task.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.9.20" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="15.9.20" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
</ItemGroup>

<ItemGroup>
<InternalsVisibleTo Include="GitVersion.MsBuild" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GitVersionCore\GitVersionCore.csproj" />
</ItemGroup>

</Project>
13 changes: 13 additions & 0 deletions src/GitVersion.MsBuild.Task/GitVersionTaskBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace GitVersion.MsBuild.Task
{
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

public abstract class GitVersionTaskBase : Task
asbjornu marked this conversation as resolved.
Show resolved Hide resolved
{
[Required]
public string SolutionDirectory { get; set; }

public bool NoFetch { get; set; }
}
}
87 changes: 87 additions & 0 deletions src/GitVersion.MsBuild.Task/LibGit2Sharp/GitLoaderContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This code originally copied from https://raw.githubusercontent.com/dotnet/sourcelink/master/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs
#if !NET461
namespace GitVersion.MsBuild.Task.LibGit2Sharp
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.Loader;
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;

public sealed class GitLoaderContext : AssemblyLoadContext
{
private readonly string[] assemblies;
public static GitLoaderContext Instance { get; private set; }

private GitLoaderContext(string[] assemblies) => this.assemblies = assemblies;

public static void Init(params string[] assemblies) => Instance = new GitLoaderContext(assemblies);

protected override Assembly Load(AssemblyName assemblyName)
{
if (assemblies.Contains(assemblyName.Name))
{
var path = Path.Combine(Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location), assemblyName.Name + ".dll");
return LoadFromAssemblyPath(path);
}

return Default.LoadFromAssemblyName(assemblyName);
}

protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
{
var modulePtr = IntPtr.Zero;

if (unmanagedDllName.StartsWith("git2-", StringComparison.Ordinal) ||
unmanagedDllName.StartsWith("libgit2-", StringComparison.Ordinal))
{
var directory = GetNativeLibraryDirectory();
var extension = GetNativeLibraryExtension();

if (!unmanagedDllName.EndsWith(extension, StringComparison.Ordinal))
{
unmanagedDllName += extension;
}

var nativeLibraryPath = Path.Combine(directory, unmanagedDllName);
if (!File.Exists(nativeLibraryPath))
{
nativeLibraryPath = Path.Combine(directory, "lib" + unmanagedDllName);
}

modulePtr = LoadUnmanagedDllFromPath(nativeLibraryPath);
}

return modulePtr != IntPtr.Zero ? modulePtr : base.LoadUnmanagedDll(unmanagedDllName);
}

internal static string GetNativeLibraryDirectory()
{
var dir = Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location);
return Path.Combine(dir, "runtimes", RuntimeIdMap.GetNativeLibraryDirectoryName(RuntimeEnvironment.GetRuntimeIdentifier()), "native");
}

private static string GetNativeLibraryExtension()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return ".dll";
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return ".dylib";
}

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return ".so";
}

throw new PlatformNotSupportedException();
}
}
}
#endif