Skip to content

Commit b6bfdaa

Browse files
committed
Workaround for GitVersion
See: GitTools/GitVersion#1097
1 parent d7ec53b commit b6bfdaa

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

GitVersion.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
assembly-versioning-scheme: MajorMinorPatch
2+
mode: ContinuousDelivery
3+
branches: {}
4+
ignore:
5+
sha: []
6+
merge-message-formats: {}

build/Build.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using JetBrains.Annotations;
56
using Nuke.Common;
67
using Nuke.Common.CI;
78
using Nuke.Common.CI.AzurePipelines;
@@ -53,7 +54,7 @@ class Build : NukeBuild
5354

5455
[Solution] readonly Solution Solution;
5556
[GitRepository] readonly GitRepository GitRepository;
56-
[GitVersion] readonly GitVersion GitVersion;
57+
[GitVersion(DisableOnUnix = true)] [CanBeNull] readonly GitVersion GitVersion;
5758

5859
AbsolutePath SourceDirectory => RootDirectory / "src";
5960
AbsolutePath TestsDirectory => RootDirectory / "test";
@@ -89,12 +90,17 @@ class Build : NukeBuild
8990
.DependsOn(Restore)
9091
.Executes(() =>
9192
{
92-
DotNetBuild(s => s
93-
.SetProjectFile(Solution)
94-
.SetConfiguration(Configuration)
95-
.SetAssemblyVersion(GitVersion.AssemblySemVer)
96-
.SetFileVersion(GitVersion.AssemblySemFileVer)
97-
.SetInformationalVersion(GitVersion.InformationalVersion)
93+
94+
DotNetBuildSettings WithGitVersion(DotNetBuildSettings settings) => GitVersion == null
95+
? settings
96+
: settings
97+
.SetAssemblyVersion(GitVersion.AssemblySemVer)
98+
.SetFileVersion(GitVersion.AssemblySemFileVer)
99+
.SetInformationalVersion(GitVersion.InformationalVersion);
100+
101+
DotNetBuild(s => WithGitVersion(s
102+
.SetProjectFile(Solution)
103+
.SetConfiguration(Configuration))
98104
.EnableNoRestore());
99105
});
100106

@@ -169,7 +175,7 @@ class Build : NukeBuild
169175
.SetNoBuild(InvokedTargets.Contains(Compile))
170176
.SetConfiguration(Configuration)
171177
.SetOutputDirectory(PackageDirectory)
172-
.SetVersion(GitVersion.NuGetVersionV2)
178+
.SetVersion(GitVersion!.NuGetVersionV2)
173179
.SetPackageReleaseNotes(GetNuGetReleaseNotes(ChangelogFile, GitRepository)));
174180
});
175181

0 commit comments

Comments
 (0)