1- using System ;
2- using System . Linq ;
31using Nuke . Common ;
42using Nuke . Common . CI ;
53using Nuke . Common . Execution ;
6- using Nuke . Common . Git ;
74using Nuke . Common . IO ;
85using Nuke . Common . ProjectModel ;
9- using Nuke . Common . Tooling ;
106using Nuke . Common . Tools . DotNet ;
7+ using Nuke . Common . Tools . OctoVersion ;
118using Nuke . Common . Utilities . Collections ;
12- using static Nuke . Common . EnvironmentInfo ;
139using static Nuke . Common . IO . FileSystemTasks ;
14- using static Nuke . Common . IO . PathConstruction ;
1510using static Nuke . Common . Tools . DotNet . DotNetTasks ;
1611
1712[ CheckBuildProjectConfigurations ]
@@ -33,6 +28,17 @@ class Build : NukeBuild
3328
3429 [ Solution ] readonly Solution Solution ;
3530
31+ [ Parameter ( "Branch name for OctoVersion to use to calculate the version number. Can be set via the environment variable OCTOVERSION_CurrentBranch." ,
32+ Name = "OCTOVERSION_CurrentBranch" ) ]
33+ readonly string BranchName ;
34+
35+ [ Parameter ( "Whether to auto-detect the branch name - this is okay for a local build, but should not be used under CI." ) ]
36+ readonly bool AutoDetectBranch = IsLocalBuild ;
37+
38+ [ OctoVersion ( UpdateBuildNumber = true , BranchParameter = nameof ( BranchName ) ,
39+ AutoDetectBranchParameter = nameof ( AutoDetectBranch ) , Framework = "net6.0" ) ]
40+ readonly OctoVersionInfo OctoVersionInfo ;
41+
3642 // For outline of original build process used by original source repository, check ./azure-pipelines/dotnet.yml
3743 Target Clean => _ => _
3844 . Before ( Restore )
@@ -56,6 +62,8 @@ class Build : NukeBuild
5662 DotNetBuild ( s => s
5763 . SetProjectFile ( Solution )
5864 . SetConfiguration ( Configuration )
65+ . SetVersion ( OctoVersionInfo . FullSemVer )
66+ . SetInformationalVersion ( OctoVersionInfo . InformationalVersion )
5967 . EnableNoRestore ( ) ) ;
6068 } ) ;
6169
@@ -97,6 +105,7 @@ class Build : NukeBuild
97105 . SetRunCodeAnalysis ( false )
98106 . SetIncludeSymbols ( false )
99107 . SetPackageId ( "Octopus.LibGit2Sharp" )
108+ . SetProperty ( "OverridePackageVersion" , OctoVersionInfo . FullSemVer )
100109 . SetNoBuild ( true )
101110 ) ;
102111 } ) ;
0 commit comments