From 1a98c45df2df9b74d3d0a09aa248ada0c196108b Mon Sep 17 00:00:00 2001 From: amitkanfer Date: Sat, 11 Nov 2023 11:28:35 +0200 Subject: [PATCH 1/5] Bumping .NET version --- .gitignore | 5 +++++ global.json | 2 +- src/build/ElastiBuild.csproj | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index a1d8eaa6..c13f70b2 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,8 @@ src/.idea/ # Test cmd files src/*.cmd + +# Executable Artifacts +src/*.exe +src/*.pdb +src/*.dll \ No newline at end of file diff --git a/global.json b/global.json index 2b8e78e1..ac084ad9 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.408" + "version": "6.0.319" } } \ No newline at end of file diff --git a/src/build/ElastiBuild.csproj b/src/build/ElastiBuild.csproj index cdab43f3..c71d99cb 100644 --- a/src/build/ElastiBuild.csproj +++ b/src/build/ElastiBuild.csproj @@ -1,7 +1,7 @@  Exe - netcoreapp3.1 + net6.0 ElastiBuild From 6bb7be7c5527fa39d3026d4080e8cbb096e81341 Mon Sep 17 00:00:00 2001 From: amitkanfer Date: Sat, 11 Nov 2023 13:30:34 +0200 Subject: [PATCH 2/5] Using nly Program files --- src/build/Properties/launchSettings.json | 10 +- .../BeatPackageCompiler.cs | 107 +++--------------- .../Properties/launchSettings.json | 5 + 3 files changed, 30 insertions(+), 92 deletions(-) diff --git a/src/build/Properties/launchSettings.json b/src/build/Properties/launchSettings.json index df8e9cfc..48e5eda3 100644 --- a/src/build/Properties/launchSettings.json +++ b/src/build/Properties/launchSettings.json @@ -5,11 +5,15 @@ "commandLineArgs": "build --cid 7.5 winlogbeat --cert-file C:\\staging\\cert\\stack-elastic-installers-sha.pfx --cert-pass C:\\staging\\cert\\stack-elastic-installers-sha-password.txt", "workingDirectory": "$(SolutionDir)" }, - "Winlogbeat 8.0": { "commandName": "Project", - "commandLineArgs": "build --cid 8.0-SNAPSHOT winlogbeat", + "commandLineArgs": "build --cid 8.11.0 winlogbeat", + "workingDirectory": "$(SolutionDir)" + }, + "filebeat": { + "commandName": "Project", + "commandLineArgs": "build --cid 8.11.0 filebeat", "workingDirectory": "$(SolutionDir)" } } -} +} \ No newline at end of file diff --git a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs index a57df212..dd86dea5 100644 --- a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs +++ b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs @@ -100,17 +100,25 @@ static void Main(string[] args) System.IO.File.ReadAllText( Path.Combine(opts.PackageInDir, MagicStrings.Files.LicenseTxt)))); - var beatConfigPath = "[CommonAppDataFolder]" + Path.Combine(companyName, productSetName, ap.CanonicalTargetName); - var beatDataPath = Path.Combine(beatConfigPath, "data"); - var beatLogsPath = Path.Combine(beatConfigPath, "logs"); - var textInfo = new CultureInfo("en-US", false).TextInfo; var serviceDisplayName = $"{companyName} {textInfo.ToTitleCase(ap.TargetName)} {ap.SemVer}"; + /* + * + * new InstallDir( + // Wix# directory parsing needs forward slash + beatsInstallPath.Replace("Folder]", "Folder]\\"), + new Dir( + ap.Version, + new Dir(ap.CanonicalTargetName, new Files(Path.Combine(opts.PackageInDir, MagicStrings.Files.All))))) + }; + */ + WixSharp.File service = null; if (pc.IsWindowsService) { service = new WixSharp.File(Path.Combine(opts.PackageInDir, exeName)); + string installedPath = ("[INSTALLDIR]" + Path.Combine(ap.Version, ap.CanonicalTargetName)); // TODO: CNDL1150 : ServiceConfig functionality is documented in the Windows Installer SDK to // "not [work] as expected." Consider replacing ServiceConfig with the @@ -131,10 +139,10 @@ static void Main(string[] args) }, Arguments = - " --path.home " + ("[INSTALLDIR]" + Path.Combine(ap.Version, ap.CanonicalTargetName)).Quote() + - " --path.config " + beatConfigPath.Quote() + - " --path.data " + beatDataPath.Quote() + - " --path.logs " + beatLogsPath.Quote() + + " --path.home " + installedPath.Quote() + + " --path.config " + installedPath.Quote() + + " --path.data " + installedPath.Quote() + + " --path.logs " + installedPath.Quote() + " -E logging.files.redirect_stderr=true", DelayedAutoStart = false, @@ -150,40 +158,19 @@ static void Main(string[] args) var packageContents = new List { - new DirFiles(Path.Combine(opts.PackageInDir, MagicStrings.Files.All), path => + new Files(Path.Combine(opts.PackageInDir, MagicStrings.Files.All), path => { var itm = path.ToLower(); bool exclude = - - // configuration will go into mutable location - itm.EndsWith(MagicStrings.Ext.DotYml, StringComparison.OrdinalIgnoreCase) || - - // we install/remove service ourselves - itm.EndsWith(MagicStrings.Ext.DotPs1, StringComparison.OrdinalIgnoreCase) || - // .exe must be excluded for service configuration to work - (pc.IsWindowsService && itm.EndsWith(exeName, StringComparison.OrdinalIgnoreCase)) - ; + (pc.IsWindowsService && itm.EndsWith(exeName, StringComparison.OrdinalIgnoreCase)); // this is an "include" filter return ! exclude; }) }; - packageContents.AddRange( - new DirectoryInfo(opts.PackageInDir) - .GetDirectories() - .Select(dir => dir.Name) - .Except(pc.MutableDirs) - .Select(dirName => - new Dir( - dirName, - new Files(Path.Combine( - opts.PackageInDir, - dirName, - MagicStrings.Files.All))))); - packageContents.Add(pc.IsWindowsService ? service : null); // Add a note to the final screen and a checkbox to open the directory of .example.yml file @@ -225,38 +212,6 @@ static void Main(string[] args) ")); - var dataContents = new DirectoryInfo(opts.PackageInDir) - .GetFiles(MagicStrings.Files.AllDotYml, SearchOption.TopDirectoryOnly) - .Select(fi => - { - var wf = new WixSharp.File(fi.FullName); - - // rename main config file to hide it from MSI engine and keep customizations - if (string.Compare( - fi.Name, - ap.CanonicalTargetName + MagicStrings.Ext.DotYml, - StringComparison.OrdinalIgnoreCase) == 0) - { - wf.Attributes.Add("Name", beatConfigExampleFileName); - wf.Id = new Id(beatConfigExampleFileId); - } - - return wf; - }) - .ToList(); - - dataContents.AddRange( - pc.MutableDirs - .Select(dirName => - { - var dirPath = Path.Combine(opts.PackageInDir, dirName); - - return Directory.Exists(dirPath) - ? new Dir(dirName, new Files(Path.Combine(dirPath, MagicStrings.Files.All))) - : null; - }) - .Where(dir => dir != null)); - // Drop CLI shim on disk var cliShimScriptPath = Path.Combine( opts.PackageOutDir, @@ -279,32 +234,6 @@ static void Main(string[] args) new Dir(ap.CanonicalTargetName, packageContents.ToArray()), new WixSharp.File(cliShimScriptPath))), - // Configration and logs - new Dir("[CommonAppDataFolder]", - new Dir(companyName, - new Dir(productSetName, - new Dir(ap.CanonicalTargetName, dataContents.ToArray()) - { - GenericItems = new [] - { - /* - This will *replace* ACL on the {beatname} directory: - - Directory tree: - NT AUTHORITY\SYSTEM:(OI)(CI)F - BUILTIN\Administrators:(OI)(CI)F - BUILTIN\Users:(CI)R - - Files: - NT AUTHORITY\SYSTEM:(ID)F - BUILTIN\Administrators:(ID)F - */ - - new MsiLockPermissionEx( - "D:PAI(A;OICI;FA;;;SY)(A;OICI;FA;;;BA)(A;CI;0x1200a9;;;BU)", - ap.Is64Bit) - } - }))) }; // CLI Shim path diff --git a/src/installer/BeatPackageCompiler/Properties/launchSettings.json b/src/installer/BeatPackageCompiler/Properties/launchSettings.json index 848d7f22..000b6c00 100644 --- a/src/installer/BeatPackageCompiler/Properties/launchSettings.json +++ b/src/installer/BeatPackageCompiler/Properties/launchSettings.json @@ -4,6 +4,11 @@ "commandName": "Project", "commandLineArgs": "--package=winlogbeat-7.5.0-windows-x86_64 -v --keep-temp-files", "workingDirectory": "$(SolutionDir)" + }, + "Filebeat": { + "commandName": "Project", + "commandLineArgs": "--package=filebeat-8.11.0-windows-x86_64 -v --keep-temp-files", + "workingDirectory": "$(SolutionDir)" } } } \ No newline at end of file From 78521c2d4e45ecf8ee1ec0244898d29c26ba82d4 Mon Sep 17 00:00:00 2001 From: amitkanfer Date: Sat, 11 Nov 2023 13:47:06 +0200 Subject: [PATCH 3/5] '6' --- .../BeatPackageCompiler/BeatPackageCompiler.cs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs index dd86dea5..a12f743a 100644 --- a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs +++ b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs @@ -103,17 +103,6 @@ static void Main(string[] args) var textInfo = new CultureInfo("en-US", false).TextInfo; var serviceDisplayName = $"{companyName} {textInfo.ToTitleCase(ap.TargetName)} {ap.SemVer}"; - /* - * - * new InstallDir( - // Wix# directory parsing needs forward slash - beatsInstallPath.Replace("Folder]", "Folder]\\"), - new Dir( - ap.Version, - new Dir(ap.CanonicalTargetName, new Files(Path.Combine(opts.PackageInDir, MagicStrings.Files.All))))) - }; - */ - WixSharp.File service = null; if (pc.IsWindowsService) { From b61b67394e016bc0458884f32f6bb5f2957f5b3b Mon Sep 17 00:00:00 2001 From: amitkanfer Date: Thu, 16 Nov 2023 09:25:39 +0200 Subject: [PATCH 4/5] added the example config file rename --- .../BeatPackageCompiler.cs | 29 ++++++++++++++++++- .../Properties/launchSettings.json | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs index a12f743a..fe2b601b 100644 --- a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs +++ b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs @@ -8,6 +8,7 @@ using ElastiBuild.Extensions; using Elastic.Installer; using WixSharp; +using WixSharp.Bootstrapper; using WixSharp.CommonTasks; namespace Elastic.PackageCompiler.Beats @@ -145,15 +146,20 @@ static void Main(string[] args) }; } + string configFileName = ap.CanonicalTargetName + MagicStrings.Ext.DotYml; + string configFileFullPath = string.Empty; + var packageContents = new List { new Files(Path.Combine(opts.PackageInDir, MagicStrings.Files.All), path => { var itm = path.ToLower(); + bool isConfigFile = itm.EndsWith(configFileName, StringComparison.OrdinalIgnoreCase); bool exclude = // .exe must be excluded for service configuration to work - (pc.IsWindowsService && itm.EndsWith(exeName, StringComparison.OrdinalIgnoreCase)); + (pc.IsWindowsService && itm.EndsWith(exeName, StringComparison.OrdinalIgnoreCase)) + || (isConfigFile); // this is an "include" filter return ! exclude; @@ -201,6 +207,27 @@ static void Main(string[] args) ")); + var dataContents = new DirectoryInfo(opts.PackageInDir) + .GetFiles(MagicStrings.Files.AllDotYml, SearchOption.TopDirectoryOnly) + .Select(fi => + { + // rename main config file to hide it from MSI engine and keep customizations + if (string.Compare( + fi.Name, + ap.CanonicalTargetName + MagicStrings.Ext.DotYml, + StringComparison.OrdinalIgnoreCase) == 0) + { + var wf = new WixSharp.File(fi.FullName); + wf.Attributes.Add("Name", beatConfigExampleFileName); + wf.Id = new Id(beatConfigExampleFileId); + return wf; + } + return null; + }) + .ToList(); + + packageContents.AddRange(dataContents); + // Drop CLI shim on disk var cliShimScriptPath = Path.Combine( opts.PackageOutDir, diff --git a/src/installer/BeatPackageCompiler/Properties/launchSettings.json b/src/installer/BeatPackageCompiler/Properties/launchSettings.json index 000b6c00..56590c03 100644 --- a/src/installer/BeatPackageCompiler/Properties/launchSettings.json +++ b/src/installer/BeatPackageCompiler/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "BeatPackageCompiler.netcore": { "commandName": "Project", - "commandLineArgs": "--package=winlogbeat-7.5.0-windows-x86_64 -v --keep-temp-files", + "commandLineArgs": "--package=winlogbeat-8.11.1-windows-x86_64 -v --keep-temp-files", "workingDirectory": "$(SolutionDir)" }, "Filebeat": { From 7b3870790dc7f7484c5888ba2ffc384d1aaf645b Mon Sep 17 00:00:00 2001 From: amitkanfer Date: Thu, 16 Nov 2023 19:41:59 +0200 Subject: [PATCH 5/5] Removing unused code --- src/installer/BeatPackageCompiler/BeatPackageCompiler.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs index fe2b601b..3914dd37 100644 --- a/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs +++ b/src/installer/BeatPackageCompiler/BeatPackageCompiler.cs @@ -146,15 +146,12 @@ static void Main(string[] args) }; } - string configFileName = ap.CanonicalTargetName + MagicStrings.Ext.DotYml; - string configFileFullPath = string.Empty; - var packageContents = new List { new Files(Path.Combine(opts.PackageInDir, MagicStrings.Files.All), path => { var itm = path.ToLower(); - bool isConfigFile = itm.EndsWith(configFileName, StringComparison.OrdinalIgnoreCase); + bool isConfigFile = itm.EndsWith(ap.CanonicalTargetName + MagicStrings.Ext.DotYml, StringComparison.OrdinalIgnoreCase); bool exclude = // .exe must be excluded for service configuration to work