@@ -15,19 +15,19 @@ internal class Build : NukeBuild
1515 {
1616 public static int Main ( ) => Execute < Build > ( x => x . Pack ) ;
1717
18- [ Parameter ( "[Optional] Update the major version (Default: Minor version will be updated)" ) ]
18+ [ Parameter ( "Update the major version (Default: Minor version will be updated)" ) ]
1919 public bool Major = false ;
2020
21- [ Parameter ( "[Optional] Update the patch version (Default: Minor version will be updated)" ) ]
21+ [ Parameter ( "Update the patch version (Default: Minor version will be updated)" ) ]
2222 public bool Patch = false ;
2323
24- [ Parameter ( "[Optional] Provide a new version for the package" ) ]
24+ [ Parameter ( "Provide a new version for the package" ) ]
2525 public readonly string ? Version = null ;
2626
27- [ Parameter ( "[Optional] The path of the doxygen bin directory (Default: C:\\ Program Files\\ doxygen\\ bin)" ) ]
27+ [ Parameter ( "The path of the doxygen bin directory (Default: C:\\ Program Files\\ doxygen\\ bin)" ) ]
2828 public readonly string DoxygenBin = "C:\\ Program Files\\ doxygen\\ bin" ;
2929
30- [ Parameter ( "[Optional] Sets that no docs should be created" ) ]
30+ [ Parameter ( "Sets that no docs should be created (Default: Automaticly updating the version from the build config) " ) ]
3131 public readonly bool NoDocs = false ;
3232
3333 [ Solution ]
@@ -50,6 +50,7 @@ internal class Build : NukeBuild
5050 . Executes ( ( ) =>
5151 {
5252 Log . Information ( "Loading the build config" ) ;
53+ Log . Information ( "File: {configFile}" , _configFile ) ;
5354
5455 // Check if config exist
5556 if ( ! File . Exists ( _configFile ) )
@@ -181,7 +182,7 @@ internal class Build : NukeBuild
181182
182183 Target Pack => _ => _
183184 . DependsOn ( Info , Compile )
184- . Triggers ( Docs )
185+ . Triggers ( Docs , UpdateConfig )
185186 . Executes ( ( ) =>
186187 {
187188 if ( Solution == null )
@@ -204,6 +205,7 @@ internal class Build : NukeBuild
204205 Target Docs => _ => _
205206 . Unlisted ( )
206207 . OnlyWhenDynamic ( ( ) => ! NoDocs )
208+ . ProceedAfterFailure ( )
207209 . Executes ( ( ) =>
208210 {
209211 if ( _workingVersion == null )
@@ -243,5 +245,33 @@ internal class Build : NukeBuild
243245 Assert . Fail ( "Failed to generate docs" ) ;
244246 }
245247 } ) ;
248+
249+ Target UpdateConfig => _ => _
250+ . Unlisted ( )
251+ . After ( Pack , Docs )
252+ . TriggeredBy ( Pack )
253+ . ProceedAfterFailure ( )
254+ . Executes ( ( ) =>
255+ {
256+ Log . Information ( "Updating the build config" ) ;
257+ Log . Information ( "File: {configFile}" , _configFile ) ;
258+
259+ if ( ! File . Exists ( _configFile ) )
260+ {
261+ Log . Information ( "The config file does not exist, it will be created" ) ;
262+ }
263+
264+ bool saveResult = ConfigHandler . SaveConfig (
265+ _configFile ,
266+ new ConfigHandler . BuildConfig ( )
267+ {
268+ CurrentVersion = _workingVersion
269+ } ) ;
270+
271+ if ( ! saveResult )
272+ {
273+ Assert . Fail ( "Failed to update the build config" ) ;
274+ }
275+ } ) ;
246276 }
247277}
0 commit comments