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

[v3.0] Add support for ARM64 variants of Debian, Ubuntu #407

Merged
merged 12 commits into from
Nov 20, 2019
26 changes: 25 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ resources:
image: andrewarnott/linux-buildagent
- container: bionic
image: microsoft/dotnet:2.1-sdk-bionic
- container: bionic-3.0
image: mcr.microsoft.com/dotnet/core/sdk:3.0-bionic
- container: disco
image: mcr.microsoft.com/dotnet/core/sdk:3.0-disco

jobs:
- job: Windows
Expand All @@ -35,7 +39,7 @@ jobs:
displayName: Install .NET Core SDK
inputs:
packageType: sdk
version: 2.1.500
version: 2.2.402
- script: dotnet --info
displayName: Show dotnet SDK info

Expand Down Expand Up @@ -65,6 +69,10 @@ jobs:
displayName: Build NuGet package and tests
workingDirectory: src

- script: dotnet publish -c $(BuildConfiguration) -o ..\nerdbank-gitversioning.npm\out\nbgv.cli\tools\netcoreapp2.1\any /bl:"$(Build.ArtifactStagingDirectory)/build_logs/nbgv_publish.binlog"
displayName: Build NuGet package and tests
workingDirectory: src\nbgv

- task: gulp@0
displayName: Build nerdbank-gitversioning NPM package
inputs:
Expand Down Expand Up @@ -149,6 +157,22 @@ jobs:
steps:
- template: azure-pipelines/xplattest-pipeline.yml

- job: Ubuntu_Bionic_3_0
dependsOn: Windows
pool:
vmImage: Ubuntu 16.04 # not a bug. we always use this pool, but use containers for the specific version
container: bionic-3.0
steps:
- template: azure-pipelines/xplattest-pipeline.yml

- job: Ubuntu_Disco
dependsOn: Windows
pool:
vmImage: Ubuntu 16.04 # not a bug. we always use this pool, but use containers for the specific version
container: disco
steps:
- template: azure-pipelines/xplattest-pipeline.yml

- job: macOS
dependsOn: Windows
pool:
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines/xplattest-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ steps:

NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")

echo "<configuration><packageSources><clear /><add key='local' value='deployables' /></packageSources></configuration>" > nuget.config &&
echo "<configuration><packageSources><add key='local' value='deployables' /></packageSources></configuration>" > nuget.config &&
AArnott marked this conversation as resolved.
Show resolved Hide resolved
dotnet new classlib -o lib &&
cd lib &&
echo '{"version":"42.42"}' > version.json &&
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.500"
"version": "2.2.402"
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
</ItemGroup>
</Project>
6 changes: 6 additions & 0 deletions src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
<PackageReference Include="Validation" Version="2.4.18" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" Version="1.6.20-beta-gfea83a8c9e" />
</ItemGroup>
<ItemGroup>
<!-- Download version 2.0.280-armpreview01 of LibGit2Sharp.NativeBinaries. This builds from the same libgit2 commit (git2-572e4d8) as
0.27.0-preview-0007, but includes arm64 binaries.
This explicit dependency should be removed when upgrading to a newer version of LibGit2Sharp. -->
<PackageDownload Include="LibGit2Sharp.NativeBinaries" Version="[2.0.280-armpreview01]" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\**\*.cs" LinkBase="Shared" />
</ItemGroup>
Expand Down
10 changes: 9 additions & 1 deletion src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ internal class GitLoaderContext : AssemblyLoadContext
{
public static readonly GitLoaderContext Instance = new GitLoaderContext();

// When invoked as a MSBuild task, the native libraries will be at
// ../runtimes. When invoked from the nbgv CLI, the libraries
// will be at ./runtimes.
// This property allows code which consumes GitLoaderContext to
// differentiate between these different locations.
// In the case of the nbgv CLI, the value is set in Program.Main()
public static string RuntimePath = "../runtimes";

protected override Assembly Load(AssemblyName assemblyName)
{
var path = Path.Combine(Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location), assemblyName.Name + ".dll");
Expand Down Expand Up @@ -53,7 +61,7 @@ protected override IntPtr LoadUnmanagedDll(string unmanagedDllName)
internal static string GetNativeLibraryDirectory()
{
var dir = Path.GetDirectoryName(typeof(GitLoaderContext).Assembly.Location);
return Path.Combine(dir, "..", "runtimes", RuntimeIdMap.GetNativeLibraryDirectoryName(RuntimeEnvironment.GetRuntimeIdentifier()), "native");
return Path.Combine(dir, RuntimePath, RuntimeIdMap.GetNativeLibraryDirectoryName(RuntimeEnvironment.GetRuntimeIdentifier()), "native");
}

private static string GetNativeLibraryExtension()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<Target Name="SetNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
<PropertyGroup>
<LibGit2SharpNativeBinaries>$(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.278\</LibGit2SharpNativeBinaries>
<LibGit2SharpNativeBinaries>$(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.280-armpreview01\</LibGit2SharpNativeBinaries>
<NuspecProperties>$(NuspecProperties);Version=$(Version);commit=$(GitCommitId);BaseOutputPath=$(OutputPath);LibGit2SharpNativeBinaries=$(LibGit2SharpNativeBinaries)</NuspecProperties>
</PropertyGroup>
</Target>
Expand Down
24 changes: 23 additions & 1 deletion src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ internal static void ParseRuntimeId(string runtimeId, out string osName, out str
"centos.7-x64",
"debian-x64",
"debian.8-x64",
"debian.9-arm64",
"debian.9-x64",
"fedora-x64",
"fedora.23-x64",
Expand Down Expand Up @@ -237,12 +238,22 @@ internal static void ParseRuntimeId(string runtimeId, out string osName, out str
"ubuntu.14.10-x64",
"ubuntu.15.04-x64",
"ubuntu.15.10-x64",
"ubuntu.16.04-arm64",
"ubuntu.16.04-x64",
"ubuntu.16.10-arm64",
"ubuntu.16.10-x64",
"ubuntu.17.04-arm64",
"ubuntu.17.04-x64",
"ubuntu.17.10-arm64",
"ubuntu.17.10-x64",
"ubuntu.18.04-arm64",
"ubuntu.18.04-x64",
"ubuntu.18.10-arm64",
"ubuntu.18.10-x64",
"ubuntu.19.04-arm64",
"ubuntu.19.04-x64",
"ubuntu.19.10-arm64",
"ubuntu.19.10-x64",
"win-x64",
"win-x64-aot",
"win-x86",
Expand Down Expand Up @@ -296,6 +307,7 @@ internal static void ParseRuntimeId(string runtimeId, out string osName, out str
"linux-x64",
"linux-x64",
"linux-x64",
"debian.9-arm64",
"ubuntu.18.04-x64",
"rhel-x64",
"rhel-x64",
Expand Down Expand Up @@ -347,12 +359,22 @@ internal static void ParseRuntimeId(string runtimeId, out string osName, out str
"linux-x64",
"linux-x64",
"linux-x64",
"ubuntu.16.04-arm64",
"linux-x64",
"ubuntu.16.10-arm64",
"linux-x64",
"ubuntu.16.04-arm64",
"linux-x64",
"ubuntu.16.04-arm64",
"linux-x64",
"debian-arm64",
"ubuntu.18.04-x64",
"debian-arm64",
"ubuntu.18.04-x64",
"debian-arm64",
"ubuntu.18.04-x64",
"debian-arm64",
"ubuntu.18.04-x64",
"linux-x64",
"win-x64",
"win-x64",
"win-x86",
Expand Down
15 changes: 15 additions & 0 deletions src/nbgv/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,21 @@ private enum ExitCodes
private static ExitCodes exitCode;

public static int Main(string[] args)
{
GitLoaderContext.RuntimePath = "./runtimes";

string thisAssemblyPath = new Uri(typeof(Program).GetTypeInfo().Assembly.CodeBase).LocalPath;

Assembly inContextAssembly = GitLoaderContext.Instance.LoadFromAssemblyPath(thisAssemblyPath);
Type innerProgramType = inContextAssembly.GetType(typeof(Program).FullName);
object innerProgram = Activator.CreateInstance(innerProgramType);

var mainInnerMethod = innerProgramType.GetMethod(nameof(MainInner), BindingFlags.Static | BindingFlags.NonPublic);
int result = (int)mainInnerMethod.Invoke(null, new object[] { args });
return result;
}

private static int MainInner(string[] args)
{
var commandText = string.Empty;
var projectPath = string.Empty;
Expand Down
19 changes: 5 additions & 14 deletions src/nbgv/nbgv.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,11 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
<Compile Include="../Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs" />
<Compile Include="../Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs" />
</ItemGroup>

<Target Name="ExpandForNpmPackage" DependsOnTargets="GenerateNuSpec" AfterTargets="GenerateNuSpec">
<PropertyGroup>
<NpmPackageLayoutDir>..\nerdbank-gitversioning.npm\out\nbgv.cli\</NpmPackageLayoutDir>
</PropertyGroup>
<ItemGroup>
<NpmPackageLayout Include="@(_PackageFiles)">
<TargetPath Condition=" '%(_PackageFiles.PackagePath)' != '' ">$(NpmPackageLayoutDir)$([System.IO.Path]::GetDirectoryName('%(_PackageFiles.PackagePath)'))\%(FileName)%(Extension)</TargetPath>
<TargetPath Condition=" '%(_PackageFiles.PackagePath)' == '' ">$(NpmPackageLayoutDir)%(FileName)%(Extension)</TargetPath>
</NpmPackageLayout>
</ItemGroup>
<Copy SourceFiles="@(NpmPackageLayout)" DestinationFiles="@(NpmPackageLayout->'%(TargetPath)')" />
</Target>

<ItemGroup>
<ProjectReference Include="..\NerdBank.GitVersioning\NerdBank.GitVersioning.csproj" />
</ItemGroup>
</Project>