33using System ;
44using System . IO ;
55using System . Linq ;
6+ using JetBrains . Annotations ;
67using Nuke . Common ;
78using Nuke . Common . Execution ;
89using Nuke . Common . IO ;
910using Nuke . Common . ProjectModel ;
1011using Nuke . Common . Tooling ;
1112using Nuke . Common . Tools . DotNet ;
1213using Nuke . Common . Tools . ILRepack ;
14+ using Nuke . Common . Tools . OctoVersion ;
1315using Nuke . Common . Utilities . Collections ;
14- using OctoVersion . Core ;
16+ using Serilog ;
1517using static Nuke . Common . IO . FileSystemTasks ;
1618using static Nuke . Common . Tools . DotNet . DotNetTasks ;
17- using Nuke . OctoVersion ;
1819
1920[ CheckBuildProjectConfigurations ]
2021[ UnsetVisualStudioEnvironmentVariables ]
@@ -24,8 +25,19 @@ class Build : NukeBuild
2425
2526 [ Solution ( GenerateProjects = true ) ] readonly Solution Solution ;
2627
27- [ NukeOctoVersion ] readonly OctoVersionInfo OctoVersionInfo ;
28+ [ Parameter (
29+ "Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI." ) ]
30+ readonly bool AutoDetectBranch = IsLocalBuild ;
2831
32+ [ Parameter (
33+ "Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch." ,
34+ Name = "OCTOVERSION_CurrentBranch" ) ]
35+ readonly string BranchName ;
36+
37+ [ OctoVersion ( UpdateBuildNumber = true , BranchParameter = nameof ( BranchName ) ,
38+ AutoDetectBranchParameter = nameof ( AutoDetectBranch ) , Framework = "net6.0" ) ]
39+ readonly OctoVersionInfo OctoVersionInfo ;
40+
2941 AbsolutePath SourceDirectory => RootDirectory / "source" ;
3042 AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts" ;
3143 AbsolutePath LocalPackagesDirectory => RootDirectory / ".." / "LocalPackages" ;
@@ -39,10 +51,11 @@ class Build : NukeBuild
3951 EnsureCleanDirectory ( ArtifactsDirectory ) ;
4052 } ) ;
4153
54+ [ PublicAPI ]
4255 Target CalculateVersion => _ => _
4356 . Executes ( ( ) =>
4457 {
45- //all the magic happens inside `[NukeOctoVersion ]` above. we just need a target for TeamCity to call
58+ //all the magic happens inside `[OctoVersion ]` above. we just need a target for TeamCity to call
4659 } ) ;
4760
4861 Target Restore => _ => _
@@ -58,7 +71,7 @@ class Build : NukeBuild
5871 . DependsOn ( Restore )
5972 . Executes ( ( ) =>
6073 {
61- Logger . Info ( "Building {0} v{1}" , Solution . Name , OctoVersionInfo . FullSemVer ) ;
74+ Log . Information ( "Building {0} v{1}" , Solution . Name , OctoVersionInfo . FullSemVer ) ;
6275
6376 DotNetBuild ( _ => _
6477 . SetProjectFile ( Solution )
@@ -144,6 +157,7 @@ class Build : NukeBuild
144157 }
145158 } ) ;
146159
160+ [ UsedImplicitly ]
147161 Target CopyToLocalPackages => _ => _
148162 . OnlyWhenStatic ( ( ) => IsLocalBuild )
149163 . TriggeredBy ( Pack )
0 commit comments