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 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..3914dd37 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 @@ -100,10 +101,6 @@ 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}"; @@ -111,6 +108,7 @@ static void Main(string[] args) 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 +129,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 +148,21 @@ 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 isConfigFile = itm.EndsWith(ap.CanonicalTargetName + MagicStrings.Ext.DotYml, StringComparison.OrdinalIgnoreCase); 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)) - ; + || (isConfigFile); // 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 @@ -229,33 +208,22 @@ static void Main(string[] args) .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) { + var wf = new WixSharp.File(fi.FullName); wf.Attributes.Add("Name", beatConfigExampleFileName); wf.Id = new Id(beatConfigExampleFileId); + return wf; } - - return wf; + return null; }) .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)); + packageContents.AddRange(dataContents); // Drop CLI shim on disk var cliShimScriptPath = Path.Combine( @@ -279,32 +247,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..56590c03 100644 --- a/src/installer/BeatPackageCompiler/Properties/launchSettings.json +++ b/src/installer/BeatPackageCompiler/Properties/launchSettings.json @@ -2,7 +2,12 @@ "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": { + "commandName": "Project", + "commandLineArgs": "--package=filebeat-8.11.0-windows-x86_64 -v --keep-temp-files", "workingDirectory": "$(SolutionDir)" } }