From ea675ac55ef328c5851a85ffc258cb04fde89eb4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 28 Oct 2019 08:31:16 -0600 Subject: [PATCH 01/22] Get macOS agent building in Azure Pipelines again Works around microsoft/azure-pipelines-image-generation#531 --- azure-pipelines/xplattest-pipeline.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/azure-pipelines/xplattest-pipeline.yml b/azure-pipelines/xplattest-pipeline.yml index 7cd78092..bf6bd833 100644 --- a/azure-pipelines/xplattest-pipeline.yml +++ b/azure-pipelines/xplattest-pipeline.yml @@ -4,6 +4,10 @@ steps: - script: dotnet --info displayName: Show dotnet SDK info +- script: echo "##vso[task.setvariable variable=DOTNET_ROOT;]/Users/runner/.dotnet" + condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) + displayName: Workaround microsoft/azure-pipelines-image-generation#531 + - task: DownloadBuildArtifacts@0 displayName: Download Build Artifacts inputs: From 2b0c747d562365ccde6ad6ee25af958243a25c62 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 28 Oct 2019 09:08:40 -0600 Subject: [PATCH 02/22] Update microsoft/azure-pipelines-image-generation#531 workaround Remove the redundant workaround and update the original to match new username on macOS --- azure-pipelines.yml | 2 +- azure-pipelines/xplattest-pipeline.yml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8c35f83e..177bdeb4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -165,6 +165,6 @@ jobs: pool: vmImage: macOS 10.13 variables: - DOTNET_ROOT: /Users/vsts/.dotnet + DOTNET_ROOT: /Users/runner/.dotnet # Workaround for microsoft/azure-pipelines-image-generation#531 steps: - template: azure-pipelines/xplattest-pipeline.yml diff --git a/azure-pipelines/xplattest-pipeline.yml b/azure-pipelines/xplattest-pipeline.yml index bf6bd833..7cd78092 100644 --- a/azure-pipelines/xplattest-pipeline.yml +++ b/azure-pipelines/xplattest-pipeline.yml @@ -4,10 +4,6 @@ steps: - script: dotnet --info displayName: Show dotnet SDK info -- script: echo "##vso[task.setvariable variable=DOTNET_ROOT;]/Users/runner/.dotnet" - condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) - displayName: Workaround microsoft/azure-pipelines-image-generation#531 - - task: DownloadBuildArtifacts@0 displayName: Download Build Artifacts inputs: From 4ca837775da818cdb3f79fb22191a82573e6c637 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 8 Nov 2019 07:20:18 -0700 Subject: [PATCH 03/22] Remove workaround for OSX DOTNET_ROOT variable Per the fix notice at https://github.com/microsoft/azure-pipelines-image-generation/issues/531#issuecomment-551450908 --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b7ef0cfe..e51f6b4a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -153,7 +153,5 @@ jobs: dependsOn: Windows pool: vmImage: macOS 10.13 - variables: - DOTNET_ROOT: /Users/vsts/.dotnet steps: - template: azure-pipelines/xplattest-pipeline.yml From 3f8791d3a5f2e7de246d47d7e0255a5ac062ab18 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 14 Nov 2019 21:04:52 -0700 Subject: [PATCH 04/22] Improve support of WPF projects Workaround for #404 till the dependent bugs we have open against NuGet are resolved. This workaround is only complete with two xml snippets added to a WPF project: Add this just under the opening `` tag: ```xml ``` Add this just above the closing `` tag: ```xml ``` This is tested to work both for .NET Framework WPF projects and .NET Core WPF projects. --- .../build/Nerdbank.GitVersioning.targets | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets index 2ce8ba2a..a0d33929 100644 --- a/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets +++ b/src/Nerdbank.GitVersioning.Tasks/build/Nerdbank.GitVersioning.targets @@ -1,23 +1,8 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - - GenerateNativeVersionInfo; - $(PrepareForBuildDependsOn); - - - - GenerateAssemblyVersionInfo; - $(PrepareResourcesDependsOn) - - - - GenerateAssemblyVersionInfo; - $(CoreCompileDependsOn) - - GetNuPkgVersion; $(VersionDependsOn) @@ -33,9 +18,6 @@ $(GetPackageVersionDependsOn) - - false - false @@ -53,6 +35,32 @@ + + + + + + false + + + + GenerateNativeVersionInfo; + $(PrepareForBuildDependsOn); + + + + GenerateAssemblyVersionInfo; + $(PrepareResourcesDependsOn) + + + + GenerateAssemblyVersionInfo; + $(CoreCompileDependsOn) + + + + + <_NBGV_BuildingRef>$(_NBGV_BuildingTag) From 18fe7c8b1a1136bf553b833177ea2637bbc52b5c Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 28 Oct 2019 12:14:47 +0000 Subject: [PATCH 05/22] Bump SourceLink to beta2 --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 1df4c543..055e017a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -19,6 +19,6 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - + From 91a3780ff647c53f591699419346da4172a3b53b Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 28 Oct 2019 12:15:50 +0000 Subject: [PATCH 06/22] Add support for Debian and Ubuntu on ARM64 --- .../RuntimeIdMap.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs b/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs index a22e250b..168d0c0a 100644 --- a/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs +++ b/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs @@ -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", @@ -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", @@ -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", @@ -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.9-arm64", + "ubuntu.18.04-x64", + "debian.9-arm64", + "ubuntu.18.04-x64", + "debian.9-arm64", + "ubuntu.18.04-x64", + "debian.9-arm64", "ubuntu.18.04-x64", - "linux-x64", "win-x64", "win-x64", "win-x86", From 2422be7afed0fa2fc73bfd8cdd43312b9e64604a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 28 Oct 2019 06:47:04 -0600 Subject: [PATCH 07/22] Enable Ubuntu 19 testing --- azure-pipelines.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e51f6b4a..8823f3c4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -149,6 +149,14 @@ jobs: 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: From 1a1811365eef4576865e7f2b50df6fdd6b3eaa64 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Sun, 17 Nov 2019 11:20:44 +0100 Subject: [PATCH 08/22] Test on bionic using both .NET Core 2.1 and 3.0 --- azure-pipelines.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 8823f3c4..3ef928fd 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 @@ -149,6 +153,14 @@ 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: From 57883593102a018e660fb04f45edf59a1126321b Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Sun, 17 Nov 2019 13:27:42 +0100 Subject: [PATCH 09/22] Use NuGet sources --- azure-pipelines/xplattest-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/xplattest-pipeline.yml b/azure-pipelines/xplattest-pipeline.yml index 599a3705..9fad686f 100644 --- a/azure-pipelines/xplattest-pipeline.yml +++ b/azure-pipelines/xplattest-pipeline.yml @@ -20,7 +20,7 @@ steps: NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}") - echo "" > nuget.config && + echo "" > nuget.config && dotnet new classlib -o lib && cd lib && echo '{"version":"42.42"}' > version.json && From 53d03171e7a78e2d7ba2bc836448241ac5a6a741 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Sun, 17 Nov 2019 22:52:30 +0100 Subject: [PATCH 10/22] nbgv: Load the libgit native libraries using the GitLoaderContext --- .../GitLoaderContext.cs | 10 +++++++++- src/nbgv/Program.cs | 15 +++++++++++++++ src/nbgv/nbgv.csproj | 5 +++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs b/src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs index b5d5fb31..36f85eee 100644 --- a/src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs +++ b/src/Nerdbank.GitVersioning.Tasks/GitLoaderContext.cs @@ -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"); @@ -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() diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index d39d0a9a..58020fcc 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -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; diff --git a/src/nbgv/nbgv.csproj b/src/nbgv/nbgv.csproj index 721f8152..f3a4dbf1 100644 --- a/src/nbgv/nbgv.csproj +++ b/src/nbgv/nbgv.csproj @@ -18,6 +18,11 @@ + + + + + From 3baf1d95bd5202733755667c0cf5d1bdcc9b3e2e Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 18 Nov 2019 10:18:06 +0100 Subject: [PATCH 11/22] Use LibGit2Sharp.NativeBinaries 2.0.280-armpreview01 --- src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj | 4 ++++ .../Nerdbank.GitVersioning.Tasks.csproj | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj index 374c0e29..113cc7b3 100644 --- a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj +++ b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj @@ -9,6 +9,10 @@ + + diff --git a/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.Tasks.csproj b/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.Tasks.csproj index 14bd1aa8..8e7fd062 100644 --- a/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.Tasks.csproj +++ b/src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.Tasks.csproj @@ -18,7 +18,7 @@ - $(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.278\ + $(NuGetPackageRoot)libgit2sharp.nativebinaries\2.0.280-armpreview01\ $(NuspecProperties);Version=$(Version);commit=$(GitCommitId);BaseOutputPath=$(OutputPath);LibGit2SharpNativeBinaries=$(LibGit2SharpNativeBinaries) From de336dd5cbf21a631153eebcad0fc678cd8bd679 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Mon, 18 Nov 2019 10:18:27 +0100 Subject: [PATCH 12/22] Update RID for Debian --- src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs b/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs index 168d0c0a..8f0c79b8 100644 --- a/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs +++ b/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs @@ -367,13 +367,13 @@ internal static void ParseRuntimeId(string runtimeId, out string osName, out str "linux-x64", "ubuntu.16.04-arm64", "linux-x64", - "debian.9-arm64", + "debian-arm64", "ubuntu.18.04-x64", - "debian.9-arm64", + "debian-arm64", "ubuntu.18.04-x64", - "debian.9-arm64", + "debian-arm64", "ubuntu.18.04-x64", - "debian.9-arm64", + "debian-arm64", "ubuntu.18.04-x64", "win-x64", "win-x64", From a9005dd2f30bef3f6e73d8d3617de17a28ce7a05 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Wed, 20 Nov 2019 10:00:42 +0100 Subject: [PATCH 13/22] Download a newer version of LibGit2Sharp.NativeBinaries --- src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj index 113cc7b3..c901086d 100644 --- a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj +++ b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj @@ -9,10 +9,10 @@ - - + From 356f467d54767e400d79a4c6ef8b37b8d239996d Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Wed, 20 Nov 2019 10:24:23 +0100 Subject: [PATCH 14/22] Use .NET Core 2.2.402 SDK --- azure-pipelines.yml | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3ef928fd..280e8482 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -39,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 diff --git a/global.json b/global.json index b62f6cc5..89b3b0f4 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "2.1.500" + "version": "2.2.402" } } From fbfe2c1fac1926bba7f291a685dc6345af0d2c73 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Wed, 20 Nov 2019 11:07:01 +0100 Subject: [PATCH 15/22] Use dotnet publish to publish nbgv for npm --- azure-pipelines.yml | 4 ++++ src/nbgv/nbgv.csproj | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 280e8482..4075f576 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -69,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/msbuild.binlog" + displayName: Build NuGet package and tests + workingDirectory: src\nbgv + - task: gulp@0 displayName: Build nerdbank-gitversioning NPM package inputs: diff --git a/src/nbgv/nbgv.csproj b/src/nbgv/nbgv.csproj index f3a4dbf1..a315294b 100644 --- a/src/nbgv/nbgv.csproj +++ b/src/nbgv/nbgv.csproj @@ -26,18 +26,4 @@ - - - - ..\nerdbank-gitversioning.npm\out\nbgv.cli\ - - - - $(NpmPackageLayoutDir)$([System.IO.Path]::GetDirectoryName('%(_PackageFiles.PackagePath)'))\%(FileName)%(Extension) - $(NpmPackageLayoutDir)%(FileName)%(Extension) - - - - - From 24c1dc4f59fcddabb0a8ca7d9e978b101d0e90d1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 20 Nov 2019 12:05:18 -0700 Subject: [PATCH 16/22] Minor cleanup --- azure-pipelines.yml | 2 +- .../NerdBank.GitVersioning.csproj | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4075f576..60de404c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -69,7 +69,7 @@ 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/msbuild.binlog" + - 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 diff --git a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj index c901086d..b7111d8d 100644 --- a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj +++ b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj @@ -9,16 +9,18 @@ - - + + + + From f3fac6ba7c16869595cd6cb8432a006cdf2dc7a1 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Thu, 21 Nov 2019 16:35:45 +0100 Subject: [PATCH 17/22] Bump LibGit2Sharp --- src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj index ef5affc5..f89c65c4 100644 --- a/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj +++ b/src/NerdBank.GitVersioning/NerdBank.GitVersioning.csproj @@ -8,7 +8,7 @@ - + From 6c4e38cb59673399eb6a4947cdf69b44fab3a1db Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 23 Nov 2019 19:23:23 -0700 Subject: [PATCH 18/22] Document `nbgv` as preferred over the old ps1 scripts Closes #410 --- readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1589d04b..778425d8 100644 --- a/readme.md +++ b/readme.md @@ -111,7 +111,13 @@ Learn more about [public releases and the git commit ID suffix](doc/public_vs_st ### How do I translate from a version to a git commit and vice versa? -A pair of Powershell scripts are included in the Nerdbank.GitVersioning NuGet package +While Nerdbank.GitVersioning calculates the version and applies it to most builds automatically, +there can be occasions where you want to do so yourself or reverse the process to determine +the commit that produced a given version. + +To do this use [the `nbgv` tool](doc/nbgv-cli.md) with the `get-version` or `get-commits` command. + +Another (deprecated) option is to use a pair of Powershell scripts are included in the Nerdbank.GitVersioning NuGet package that can help you to translate between the two representations. tools\Get-CommitId.ps1 From 9f3191ef06683c12b0263d832a4217b7acf632a3 Mon Sep 17 00:00:00 2001 From: Dan Schnau Date: Tue, 3 Dec 2019 17:08:07 -0500 Subject: [PATCH 19/22] fix typo in versionJson.md --- doc/versionJson.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/versionJson.md b/doc/versionJson.md index b413abd4..4721d5bc 100644 --- a/doc/versionJson.md +++ b/doc/versionJson.md @@ -51,7 +51,7 @@ The content of the version.json file is a JSON serialized object with these prop "branchName" : "v{version}", "versionIncrement" : "minor", "firstUnstableTag" : "alpha" - } + }, "inherit": false // optional. Set to true in secondary version.json files used to tweak settings for subsets of projects. } ``` From a60cc561cdb0bfcdb882d706332a7c1f0a6a45f9 Mon Sep 17 00:00:00 2001 From: sjroesink Date: Wed, 18 Dec 2019 10:44:38 +0100 Subject: [PATCH 20/22] Fix typo in versionIncrement property --- doc/nbgv-cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/nbgv-cli.md b/doc/nbgv-cli.md index 9bd6b1ac..0beae834 100644 --- a/doc/nbgv-cli.md +++ b/doc/nbgv-cli.md @@ -118,7 +118,7 @@ The behaviour of the `prepare-release` command can be customized in | Property | Default value | Description | |------------------|----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------| | branchName | `v{version}` | Defines the format of release branch names. The value must include a `{version}` placeholder. | -| versionIncremnt | `minor` | Specifies which part of the version on the current branch is incremented when preparing a release. Allowed values are `major`, `minor` and `build`. | +| versionIncrement | `minor` | Specifies which part of the version on the current branch is incremented when preparing a release. Allowed values are `major`, `minor` and `build`. | | firstUnstableTag | `alpha` | Specified the unstable tag to use for the main branch. | ## Learn more From aa92a685f6dba5569c8a035290a3f0e795b81af4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 20 Dec 2019 16:12:04 -0700 Subject: [PATCH 21/22] Side on always emitting $schema property Fixes #373 --- src/NerdBank.GitVersioning.Tests/VersionFileTests.cs | 2 +- src/NerdBank.GitVersioning/VersionFile.cs | 5 +++-- src/nbgv/Program.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/NerdBank.GitVersioning.Tests/VersionFileTests.cs b/src/NerdBank.GitVersioning.Tests/VersionFileTests.cs index 7e959d04..2173802c 100644 --- a/src/NerdBank.GitVersioning.Tests/VersionFileTests.cs +++ b/src/NerdBank.GitVersioning.Tests/VersionFileTests.cs @@ -128,7 +128,7 @@ public void SetVersion_WritesSimplestFile(string version, string assemblyVersion VersionHeightOffset = versionHeightOffset, Inherit = inherit, }; - string pathWritten = VersionFile.SetVersion(this.RepoPath, versionOptions); + string pathWritten = VersionFile.SetVersion(this.RepoPath, versionOptions, includeSchemaProperty: false); string actualFileContent = File.ReadAllText(pathWritten); this.Logger.WriteLine(actualFileContent); diff --git a/src/NerdBank.GitVersioning/VersionFile.cs b/src/NerdBank.GitVersioning/VersionFile.cs index 82dc07a8..6df2fb13 100644 --- a/src/NerdBank.GitVersioning/VersionFile.cs +++ b/src/NerdBank.GitVersioning/VersionFile.cs @@ -226,6 +226,7 @@ public static bool IsVersionDefined(string projectDirectory) /// /// Writes the version.json file to a directory within a repo with the specified version information. + /// The $schema property is included. /// /// /// The path to the directory in which to write the version.json file. @@ -234,7 +235,7 @@ public static bool IsVersionDefined(string projectDirectory) /// /// The version information to write to the file. /// The path to the file written. - public static string SetVersion(string projectDirectory, VersionOptions version) => SetVersion(projectDirectory, version, includeSchemaProperty: false); + public static string SetVersion(string projectDirectory, VersionOptions version) => SetVersion(projectDirectory, version, includeSchemaProperty: true); /// /// Writes the version.json file to a directory within a repo with the specified version information. @@ -291,7 +292,7 @@ public static string SetVersion(string projectDirectory, VersionOptions version, /// The path to the file written. public static string SetVersion(string projectDirectory, Version version, string unstableTag = null) { - return SetVersion(projectDirectory, VersionOptions.FromVersion(version, unstableTag)); + return SetVersion(projectDirectory, VersionOptions.FromVersion(version, unstableTag), includeSchemaProperty: false); } /// diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs index 58020fcc..04af13ee 100644 --- a/src/nbgv/Program.cs +++ b/src/nbgv/Program.cs @@ -229,7 +229,7 @@ private static ExitCodes OnInstallCommand(string versionJsonRoot, string version } else { - string versionJsonPath = VersionFile.SetVersion(versionJsonRoot, options, includeSchemaProperty: true); + string versionJsonPath = VersionFile.SetVersion(versionJsonRoot, options); LibGit2Sharp.Commands.Stage(repository, versionJsonPath); } From 8c00102434e11017df8be2ca1f7a2f5d154bf69b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 21 Dec 2019 09:40:40 -0700 Subject: [PATCH 22/22] Always use `Branch.Tip` instead of `Branch.Commits.First()` More fixes like the one required to fix #384 --- .../BuildIntegrationTests.cs | 16 ++++++++-------- src/NerdBank.GitVersioning/GitExtensions.cs | 8 ++++---- src/NerdBank.GitVersioning/VersionFile.cs | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs b/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs index a3268df9..2e19ee42 100644 --- a/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs +++ b/src/NerdBank.GitVersioning.Tests/BuildIntegrationTests.cs @@ -80,7 +80,7 @@ private void Init() } } - private string CommitIdShort => this.Repo.Head.Commits.First().Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength); + private string CommitIdShort => this.Repo.Head.Tip.Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength); protected override void Dispose(bool disposing) { @@ -183,8 +183,8 @@ public async Task GetBuildVersion_In_Git_But_Head_Lacks_VersionFile() this.WriteVersionFile("3.4"); Assumes.True(repo.Index[VersionFile.JsonFileName] == null); var buildResult = await this.BuildAsync(); - Assert.Equal("3.4.0." + repo.Head.Commits.First().GetIdAsVersion().Revision, buildResult.BuildVersion); - Assert.Equal("3.4.0+" + repo.Head.Commits.First().Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength), buildResult.AssemblyInformationalVersion); + Assert.Equal("3.4.0." + repo.Head.Tip.GetIdAsVersion().Revision, buildResult.BuildVersion); + Assert.Equal("3.4.0+" + repo.Head.Tip.Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength), buildResult.AssemblyInformationalVersion); } [Fact] @@ -208,8 +208,8 @@ public async Task GetBuildVersion_In_Git_No_VersionFile_At_All() var repo = new Repository(this.RepoPath); // do not assign Repo property to avoid commits being generated later repo.Commit("empty", this.Signer, this.Signer, new CommitOptions { AllowEmptyCommit = true }); var buildResult = await this.BuildAsync(); - Assert.Equal("0.0.0." + repo.Head.Commits.First().GetIdAsVersion().Revision, buildResult.BuildVersion); - Assert.Equal("0.0.0+" + repo.Head.Commits.First().Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength), buildResult.AssemblyInformationalVersion); + Assert.Equal("0.0.0." + repo.Head.Tip.GetIdAsVersion().Revision, buildResult.BuildVersion); + Assert.Equal("0.0.0+" + repo.Head.Tip.Id.Sha.Substring(0, VersionOptions.DefaultGitCommitIdShortFixedLength), buildResult.AssemblyInformationalVersion); } [Fact] @@ -288,7 +288,7 @@ public async Task GetBuildVersion_StableRelease() var buildResult = await this.BuildAsync(); this.AssertStandardProperties(VersionOptions.FromVersion(new Version(majorMinorVersion)), buildResult); - Version version = this.Repo.Head.Commits.First().GetIdAsVersion(); + Version version = this.Repo.Head.Tip.GetIdAsVersion(); Assert.Equal($"{version.Major}.{version.Minor}.{buildResult.GitVersionHeight}", buildResult.NuGetPackageVersion); } @@ -1003,8 +1003,8 @@ private void AssertStandardProperties(VersionOptions versionOptions, BuildResult Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersion3Components); Assert.Equal(idAsVersion.Build.ToString(), buildResult.BuildVersionNumberComponent); Assert.Equal($"{idAsVersion.Major}.{idAsVersion.Minor}.{idAsVersion.Build}", buildResult.BuildVersionSimple); - Assert.Equal(this.Repo.Head.Commits.First().Id.Sha, buildResult.GitCommitId); - Assert.Equal(this.Repo.Head.Commits.First().Author.When.UtcTicks.ToString(CultureInfo.InvariantCulture), buildResult.GitCommitDateTicks); + Assert.Equal(this.Repo.Head.Tip.Id.Sha, buildResult.GitCommitId); + Assert.Equal(this.Repo.Head.Tip.Author.When.UtcTicks.ToString(CultureInfo.InvariantCulture), buildResult.GitCommitDateTicks); Assert.Equal(commitIdShort, buildResult.GitCommitIdShort); Assert.Equal(versionHeight.ToString(), buildResult.GitVersionHeight); Assert.Equal($"{version.Major}.{version.Minor}", buildResult.MajorMinorVersion); diff --git a/src/NerdBank.GitVersioning/GitExtensions.cs b/src/NerdBank.GitVersioning/GitExtensions.cs index 92851157..2d063fc6 100644 --- a/src/NerdBank.GitVersioning/GitExtensions.cs +++ b/src/NerdBank.GitVersioning/GitExtensions.cs @@ -108,7 +108,7 @@ public static int GetVersionHeight(this Repository repo, string repoRelativeProj /// The height of the branch till the version is changed. public static int GetVersionHeight(this Branch branch, string repoRelativeProjectDirectory = null) { - return GetVersionHeight(branch.Commits.First(), repoRelativeProjectDirectory); + return GetVersionHeight(branch.Tip ?? throw new InvalidOperationException("No commit exists."), repoRelativeProjectDirectory); } /// @@ -143,7 +143,7 @@ public static int GetHeight(this Commit commit, Func continueStepp /// The height of the branch. public static int GetHeight(this Branch branch, Func continueStepping = null) { - return GetHeight(branch.Commits.First(), continueStepping); + return GetHeight(branch.Tip ?? throw new InvalidOperationException("No commit exists."), continueStepping); } /// @@ -241,7 +241,7 @@ public static Version GetIdAsVersion(this Repository repo, string repoRelativePr { Requires.NotNull(repo, nameof(repo)); - var headCommit = repo.Head.Commits.FirstOrDefault(); + var headCommit = repo.Head.Tip; VersionOptions workingCopyVersionOptions, committedVersionOptions; if (IsVersionFileChangedInWorkingCopy(repo, repoRelativeProjectDirectory, out committedVersionOptions, out workingCopyVersionOptions)) { @@ -803,7 +803,7 @@ internal static Version GetIdAsVersionHelper(this Commit commit, VersionOptions private static bool IsVersionFileChangedInWorkingCopy(Repository repo, string repoRelativeProjectDirectory, out VersionOptions committedVersion, out VersionOptions workingCopyVersion) { Requires.NotNull(repo, nameof(repo)); - Commit headCommit = repo.Head.Commits.FirstOrDefault(); + Commit headCommit = repo.Head.Tip; committedVersion = VersionFile.GetVersion(headCommit, repoRelativeProjectDirectory); if (!repo.Info.IsBare) diff --git a/src/NerdBank.GitVersioning/VersionFile.cs b/src/NerdBank.GitVersioning/VersionFile.cs index 6df2fb13..961322a6 100644 --- a/src/NerdBank.GitVersioning/VersionFile.cs +++ b/src/NerdBank.GitVersioning/VersionFile.cs @@ -128,7 +128,7 @@ public static VersionOptions GetVersion(LibGit2Sharp.Repository repo, string rep return workingCopyVersion; } - return GetVersion(repo.Head.Commits.FirstOrDefault(), repoRelativeProjectDirectory); + return GetVersion(repo.Head.Tip, repoRelativeProjectDirectory); } ///