static void ImportLicenseInstall(Session session, MSILogger logger) { logger.Info("Checking for license file"); var licenseFilePropertyValue = session["LICENSEFILE"]; if (string.IsNullOrWhiteSpace(licenseFilePropertyValue)) { return; } logger.Info($"LICENSEFILE: {licenseFilePropertyValue}"); var currentDirectory = session["CURRENTDIRECTORY"]; var licenseFilePath = Environment.ExpandEnvironmentVariables(Path.IsPathRooted(licenseFilePropertyValue) ? licenseFilePropertyValue : Path.Combine(currentDirectory, licenseFilePropertyValue)); logger.Info($"Expanded license filepath to : {licenseFilePropertyValue}"); if (File.Exists(licenseFilePath)) { logger.Info($"File Exists : {licenseFilePropertyValue}"); string errormessage; if (!LicenseManager.TryImportLicense(licenseFilePath, out errormessage)) { logger.Error(errormessage); } } else { logger.Error($"The specified license install file was not found : '{licenseFilePath}'"); } }
static void UnattendedInstall(Session session, MSILogger logger, UnattendServiceControlInstaller unattendedInstaller) { logger.Info("Checking for unattended file"); var unattendedFilePropertyValue = session["UNATTENDEDFILE"]; if (string.IsNullOrWhiteSpace(unattendedFilePropertyValue)) { return; } var serviceAccount = session["SERVICEACCOUNT"]; var password = session["PASSWORD"]; logger.Info($"UNATTENDEDFILE: {unattendedFilePropertyValue}"); var currentDirectory = session["CURRENTDIRECTORY"]; var unattendedFilePath = Environment.ExpandEnvironmentVariables(Path.IsPathRooted(unattendedFilePropertyValue) ? unattendedFilePropertyValue : Path.Combine(currentDirectory, unattendedFilePropertyValue)); logger.Info($"Expanded unattended filepath to : {unattendedFilePropertyValue}"); if (File.Exists(unattendedFilePath)) { logger.Info($"File Exists : {unattendedFilePropertyValue}"); var instanceToInstallDetails = ServiceControlNewInstance.Load(unattendedFilePath); if (!string.IsNullOrWhiteSpace(serviceAccount)) { instanceToInstallDetails.ServiceAccount = serviceAccount; instanceToInstallDetails.ServiceAccountPwd = password; } unattendedInstaller.Add(instanceToInstallDetails, s => false); } else { logger.Error($"The specified unattended install file was not found : '{unattendedFilePath}'"); } }