diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 8c35f83e..1dadc165 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -18,6 +18,8 @@ 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
@@ -37,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
@@ -67,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:
@@ -151,6 +157,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:
@@ -164,7 +178,5 @@ jobs:
dependsOn: Windows
pool:
vmImage: macOS 10.13
- variables:
- DOTNET_ROOT: /Users/vsts/.dotnet
steps:
- template: azure-pipelines/xplattest-pipeline.yml
diff --git a/azure-pipelines/xplattest-pipeline.yml b/azure-pipelines/xplattest-pipeline.yml
index 7cd78092..d672a37e 100644
--- a/azure-pipelines/xplattest-pipeline.yml
+++ b/azure-pipelines/xplattest-pipeline.yml
@@ -21,6 +21,8 @@ steps:
NBGV_NuGetPackageVersion=$([[ $PkgFileName =~ Nerdbank.GitVersioning\.(.*)\.nupkg ]] && echo "${BASH_REMATCH[1]}")
echo "" > nuget.config &&
+ dotnet new classlib -o lib &&
+ cd lib &&
echo '{"version":"42.42"}' > version.json &&
git init &&
git add version.json &&
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
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.
}
```
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"
}
}
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
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
-
+
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.Tests/VersionFileTests.cs b/src/NerdBank.GitVersioning.Tests/VersionFileTests.cs
index 398428f9..e9d611e4 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/GitExtensions.cs b/src/NerdBank.GitVersioning/GitExtensions.cs
index 59271e17..568fc937 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);
}
///
@@ -177,7 +177,7 @@ public static int GetHeight(this Branch branch, Func continueStepp
/// The height of the branch.
public static int GetHeight(this Branch branch, string repoRelativeProjectDirectory, Func continueStepping = null)
{
- return GetHeight(branch.Commits.First(), repoRelativeProjectDirectory, continueStepping);
+ return GetHeight(branch.Tip ?? throw new InvalidOperationException("No commit exists."), repoRelativeProjectDirectory, continueStepping);
}
///
@@ -285,7 +285,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))
{
@@ -889,7 +889,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/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 @@
-
+
diff --git a/src/NerdBank.GitVersioning/VersionFile.cs b/src/NerdBank.GitVersioning/VersionFile.cs
index 82dc07a8..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);
}
///
@@ -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/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/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs b/src/Nerdbank.GitVersioning.Tasks/RuntimeIdMap.cs
index a22e250b..8f0c79b8 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-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",
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)
diff --git a/src/nbgv/Program.cs b/src/nbgv/Program.cs
index d39d0a9a..04af13ee 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;
@@ -214,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);
}
diff --git a/src/nbgv/nbgv.csproj b/src/nbgv/nbgv.csproj
index 721f8152..a315294b 100644
--- a/src/nbgv/nbgv.csproj
+++ b/src/nbgv/nbgv.csproj
@@ -19,20 +19,11 @@
-
+
+
-
-
- ..\nerdbank-gitversioning.npm\out\nbgv.cli\
-
-
-
- $(NpmPackageLayoutDir)$([System.IO.Path]::GetDirectoryName('%(_PackageFiles.PackagePath)'))\%(FileName)%(Extension)
- $(NpmPackageLayoutDir)%(FileName)%(Extension)
-
-
-
-
-
+
+
+