@@ -34,7 +34,7 @@ partial class Build : NukeBuild
3434 /// - JetBrains Rider https://nuke.build/rider
3535 /// - Microsoft VisualStudio https://nuke.build/visualstudio
3636 /// - Microsoft VSCode https://nuke.build/vscode
37- public static int Main ( ) => Execute < Build > ( x => x . Test ) ;
37+ public static int Main ( ) => Execute < Build > ( x => x . Test ) ;
3838
3939 [ Parameter ( "Configuration to build - Default is 'Debug' (local) or 'Release' (server)" ) ]
4040 readonly Configuration Configuration = IsLocalBuild ? Configuration . Debug : Configuration . Release ;
@@ -120,7 +120,7 @@ Version Version
120120 ChocolateyDirectory / $ "logexpert.{ VersionString } .nupkg"
121121 ] ;
122122
123- protected override void OnBuildInitialized ( )
123+ protected override void OnBuildInitialized ( )
124124 {
125125 SetVariable ( "DOTNET_CLI_TELEMETRY_OPTOUT" , "1" ) ;
126126
@@ -191,6 +191,58 @@ protected override void OnBuildInitialized()
191191 . SetMaxCpuCount ( Environment . ProcessorCount ) ) ;
192192 } ) ;
193193
194+ AbsolutePath PluginHashGeneratorProject => SourceDirectory / "PluginHashGenerator.Tool" / "PluginHashGenerator.Tool.csproj" ;
195+
196+ AbsolutePath PluginHashGeneratedFile => SourceDirectory / "PluginRegistry" / "PluginHashGenerator.Generated.cs" ;
197+
198+ Target GeneratePluginHashes => _ => _
199+ . After ( Compile )
200+ . OnlyWhenStatic ( ( ) => Configuration == Configuration . Release )
201+ . Executes ( ( ) =>
202+ {
203+ var pluginsDir = OutputDirectory / "plugins" ;
204+ var pluginsx86Dir = OutputDirectory / "pluginsx86" ;
205+
206+ // Check if any plugins exist
207+ if ( ! pluginsDir . DirectoryExists ( ) && ! pluginsx86Dir . DirectoryExists ( ) )
208+ {
209+ Log . Warning ( "No plugins directories found. Skipping plugin hash generation." ) ;
210+ return ;
211+ }
212+
213+ Log . Information ( "Generating plugin hashes..." ) ;
214+ Log . Information ( $ " Output Path: { OutputDirectory } ") ;
215+ Log . Information ( $ " Target File: { PluginHashGeneratedFile } ") ;
216+ Log . Information ( $ " Configuration: { Configuration } ") ;
217+
218+ try
219+ {
220+ DotNetRun ( s => s
221+ . SetProjectFile ( PluginHashGeneratorProject )
222+ . SetApplicationArguments ( [ OutputDirectory , PluginHashGeneratedFile , Configuration ] )
223+ . SetProcessWorkingDirectory ( RootDirectory ) ) ;
224+
225+ Log . Information ( "Plugin hashes generated successfully" ) ;
226+
227+ // Rebuild PluginRegistry project to include the generated file
228+ // IMPORTANT: Set OutputPath to match the main build output directory
229+ Log . Information ( "Rebuilding PluginRegistry to include generated hashes..." ) ;
230+ MSBuild ( s => s
231+ . SetTargetPath ( SourceDirectory / "PluginRegistry" / "LogExpert.PluginRegistry.csproj" )
232+ . SetTargets ( "Build" )
233+ . SetConfiguration ( Configuration )
234+ . SetProperty ( "OutputPath" , OutputDirectory )
235+ . SetMaxCpuCount ( Environment . ProcessorCount ) ) ;
236+
237+ Log . Information ( "PluginRegistry rebuilt successfully to {OutputDir}" , OutputDirectory ) ;
238+ }
239+ catch ( Exception ex )
240+ {
241+ Log . Error ( ex , "Failed to generate plugin hashes" ) ;
242+ throw ;
243+ }
244+ } ) ;
245+
194246 Target Test => _ => _
195247 . DependsOn ( Compile )
196248 . Executes ( ( ) =>
@@ -308,42 +360,25 @@ protected override void OnBuildInitialized()
308360 . SetVersion ( VersionString ) ) ;
309361 } ) ;
310362
311- Target ColumnizerLibCreateNuget => _ => _
312- . DependsOn ( Compile , Test )
313- . Executes ( ( ) =>
314- {
315- var columnizerFolder = SourceDirectory / "ColumnizerLib" ;
316-
317- NuGetTasks . NuGetPack ( s =>
318- {
319- s = s . SetTargetPath ( columnizerFolder / "ColumnizerLib.csproj" )
320- . EnableBuild ( )
321- . SetConfiguration ( Configuration )
322- . SetProperty ( "version" , VersionString )
323- . SetOutputDirectory ( BinDirectory ) ;
324-
325- return s ;
326- } ) ;
327- } ) ;
328-
329363 Target Pack => _ => _
330- . DependsOn ( BuildChocolateyPackage , CreatePackage , PackageSftpFileSystem , ColumnizerLibCreate , CopyLicenses ) ;
364+ . DependsOn ( BuildChocolateyPackage , CreatePackage , PackageSftpFileSystem , ColumnizerLibCreate , CopyLicenses , GeneratePluginHashes , CreateSetup ) ;
331365
332366 Target CopyFilesForSetup => _ => _
333367 . DependsOn ( Compile )
334368 . After ( Test )
335369 . Executes ( ( ) =>
336370 {
337- OutputDirectory . Copy ( SetupDirectory , ExistsPolicy . DirectoryMerge ) ;
371+ OutputDirectory . Copy ( SetupDirectory , ExistsPolicy . MergeAndOverwriteIfNewer ) ;
338372 SetupDirectory . GlobFiles ( ExcludeFileGlob ) . ForEach ( file => file . DeleteFile ( ) ) ;
339373
340374 SetupDirectory . GlobDirectories ( ExcludeDirectoryGlob ) . ForEach ( dir => dir . DeleteDirectory ( ) ) ;
341375 } ) ;
342376
343377 Target CreateSetup => _ => _
344- . DependsOn ( CopyFilesForSetup , ChangeVersionNumber )
378+ . DependsOn ( CopyFilesForSetup , ChangeVersionNumber , Compile )
345379 . Before ( Publish )
346- . OnlyWhenStatic ( ( ) => Configuration == "Release" )
380+ . After ( GeneratePluginHashes )
381+ . OnlyWhenStatic ( ( ) => Configuration == Configuration . Release )
347382 . Executes ( ( ) =>
348383 {
349384 var publishCombinations =
@@ -498,7 +533,7 @@ protected override void OnBuildInitialized()
498533 }
499534 } ) ;
500535
501- private void ExecuteInnoSetup ( AbsolutePath innoPath )
536+ private void ExecuteInnoSetup ( AbsolutePath innoPath )
502537 {
503538 Process proc = new ( ) ;
504539
@@ -520,12 +555,12 @@ private void ExecuteInnoSetup(AbsolutePath innoPath)
520555 }
521556 }
522557
523- private string ReplaceVersionMatch ( Match match , string replacement )
558+ private string ReplaceVersionMatch ( Match match , string replacement )
524559 {
525560 return $ "{ match . Groups [ 1 ] } { replacement } { match . Groups [ 3 ] } ";
526561 }
527562
528- private void TransformTemplateFile ( AbsolutePath path , bool deleteTemplate )
563+ private void TransformTemplateFile ( AbsolutePath path , bool deleteTemplate )
529564 {
530565 string text = path . ReadAllText ( ) ;
531566 text = text . Replace ( "##version##" , VersionString ) ;
@@ -539,20 +574,20 @@ private void TransformTemplateFile(AbsolutePath path, bool deleteTemplate)
539574 }
540575
541576 [ GeneratedRegex ( @"(\[assembly: AssemblyInformationalVersion\("")([^""]*)(""\)\])" ) ]
542- private static partial Regex AssemblyInformationalVersion ( ) ;
577+ private static partial Regex AssemblyInformationalVersion ( ) ;
543578
544579 [ GeneratedRegex ( @"(\[assembly: AssemblyVersion\("")([^""]*)(""\)\])" ) ]
545- private static partial Regex AssemblyVersion ( ) ;
580+ private static partial Regex AssemblyVersion ( ) ;
546581
547582 [ GeneratedRegex ( @"(\[assembly: AssemblyConfiguration\()(""[^""]*"")(\)\])" ) ]
548- private static partial Regex AssemblyConfiguration ( ) ;
583+ private static partial Regex AssemblyConfiguration ( ) ;
549584
550585 [ GeneratedRegex ( @"(\[assembly: AssemblyFileVersion\("")([^""]*)(""\)\])" ) ]
551- private static partial Regex AssemblyFileVersion ( ) ;
586+ private static partial Regex AssemblyFileVersion ( ) ;
552587
553588 [ GeneratedRegex ( @"\w\w{2}[_]p?[tso]?[erzliasx]+[_rhe]{5}" , RegexOptions . IgnoreCase , "en-GB" ) ]
554- private static partial Regex SFTPPlugin ( ) ;
589+ private static partial Regex SFTPPlugin ( ) ;
555590
556591 [ GeneratedRegex ( "\\ .template$" ) ]
557- private static partial Regex TemplateRegex ( ) ;
592+ private static partial Regex TemplateRegex ( ) ;
558593}
0 commit comments