Skip to content

Commit

Permalink
Workaround for GitVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
kthompson committed Nov 18, 2021
1 parent f88a0f5 commit 6db74a8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
6 changes: 6 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDelivery
branches: {}
ignore:
sha: []
merge-message-formats: {}
22 changes: 14 additions & 8 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.AzurePipelines;
Expand Down Expand Up @@ -53,7 +54,7 @@ class Build : NukeBuild

[Solution] readonly Solution Solution;
[GitRepository] readonly GitRepository GitRepository;
[GitVersion] readonly GitVersion GitVersion;
[GitVersion(DisableOnUnix = true)] [CanBeNull] readonly GitVersion GitVersion;

AbsolutePath SourceDirectory => RootDirectory / "src";
AbsolutePath TestsDirectory => RootDirectory / "test";
Expand Down Expand Up @@ -86,12 +87,17 @@ class Build : NukeBuild
.DependsOn(Restore)
.Executes(() =>
{
DotNetBuild(s => s
.SetProjectFile(Solution)
.SetConfiguration(Configuration)
.SetAssemblyVersion(GitVersion.AssemblySemVer)
.SetFileVersion(GitVersion.AssemblySemFileVer)
.SetInformationalVersion(GitVersion.InformationalVersion)

DotNetBuildSettings WithGitVersion(DotNetBuildSettings settings) => GitVersion == null
? settings
: settings
.SetAssemblyVersion(GitVersion.AssemblySemVer)
.SetFileVersion(GitVersion.AssemblySemFileVer)
.SetInformationalVersion(GitVersion.InformationalVersion);

DotNetBuild(s => WithGitVersion(s
.SetProjectFile(Solution)
.SetConfiguration(Configuration))
.EnableNoRestore());
});

Expand Down Expand Up @@ -166,7 +172,7 @@ class Build : NukeBuild
.SetNoBuild(InvokedTargets.Contains(Compile))
.SetConfiguration(Configuration)
.SetOutputDirectory(PackageDirectory)
.SetVersion(GitVersion.NuGetVersionV2)
.SetVersion(GitVersion!.NuGetVersionV2)
.SetPackageReleaseNotes(GetNuGetReleaseNotes(ChangelogFile, GitRepository)));
});

Expand Down

0 comments on commit 6db74a8

Please sign in to comment.