|
2 | 2 | using System.Collections.Generic;
|
3 | 3 | using System.IO;
|
4 | 4 | using System.Linq;
|
| 5 | +using JetBrains.Annotations; |
5 | 6 | using Nuke.Common;
|
6 | 7 | using Nuke.Common.CI;
|
7 | 8 | using Nuke.Common.CI.AzurePipelines;
|
@@ -53,7 +54,7 @@ class Build : NukeBuild
|
53 | 54 |
|
54 | 55 | [Solution] readonly Solution Solution;
|
55 | 56 | [GitRepository] readonly GitRepository GitRepository;
|
56 |
| - [GitVersion] readonly GitVersion GitVersion; |
| 57 | + [GitVersion(DisableOnUnix = true)] [CanBeNull] readonly GitVersion GitVersion; |
57 | 58 |
|
58 | 59 | AbsolutePath SourceDirectory => RootDirectory / "src";
|
59 | 60 | AbsolutePath TestsDirectory => RootDirectory / "test";
|
@@ -89,12 +90,17 @@ class Build : NukeBuild
|
89 | 90 | .DependsOn(Restore)
|
90 | 91 | .Executes(() =>
|
91 | 92 | {
|
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)) |
98 | 104 | .EnableNoRestore());
|
99 | 105 | });
|
100 | 106 |
|
@@ -169,7 +175,7 @@ class Build : NukeBuild
|
169 | 175 | .SetNoBuild(InvokedTargets.Contains(Compile))
|
170 | 176 | .SetConfiguration(Configuration)
|
171 | 177 | .SetOutputDirectory(PackageDirectory)
|
172 |
| - .SetVersion(GitVersion.NuGetVersionV2) |
| 178 | + .SetVersion(GitVersion!.NuGetVersionV2) |
173 | 179 | .SetPackageReleaseNotes(GetNuGetReleaseNotes(ChangelogFile, GitRepository)));
|
174 | 180 | });
|
175 | 181 |
|
|
0 commit comments