/// <summary>
        /// Gets a data package, either by downloading one or using the last one that was downloaded. Returns the path to the ZIP file for the package. Also
        /// archives downloaded data packages and deletes those that are too old to be useful. Installation Support Utility use only.
        /// </summary>
        public string GetDataPackage(bool forceNewPackageDownload, OperationResult operationResult)
        {
            var dataExportToRsisWebSiteNotPermitted = InstallationTypeElements is LiveInstallationElements liveInstallationElements &&
                                                      liveInstallationElements.DataExportToRsisWebSiteNotPermitted;

            if (dataExportToRsisWebSiteNotPermitted ? !File.Exists(IsuStatics.GetDataPackageZipFilePath(FullName)) : !DataPackageSize.HasValue)
            {
                return("");
            }

            var downloadedPackagesFolder = EwlStatics.CombinePaths(ConfigurationLogic.DownloadedDataPackagesFolderPath, FullName);

            var packageZipFilePath = "";

            // See if we can re-use an existing package.
            if (!forceNewPackageDownload && Directory.Exists(downloadedPackagesFolder))
            {
                var downloadedPackages = IoMethods.GetFilePathsInFolder(downloadedPackagesFolder);
                if (downloadedPackages.Any())
                {
                    packageZipFilePath = downloadedPackages.First();
                }
            }

            // Download a package from RSIS if the user forces this behavior or if there is no package available on disk.
            if (forceNewPackageDownload || packageZipFilePath.Length == 0)
            {
                packageZipFilePath = EwlStatics.CombinePaths(downloadedPackagesFolder, "{0}-Package.zip".FormatWith(DateTime.Now.ToString("yyyy-MM-dd")));

                // If the update data installation is a live installation for which data export to the RSIS web site is not permitted, get the data package from disk.
                if (dataExportToRsisWebSiteNotPermitted)
                {
                    IoMethods.CopyFile(IsuStatics.GetDataPackageZipFilePath(FullName), packageZipFilePath);
                }
                else
                {
                    operationResult.TimeSpentWaitingForNetwork =
                        EwlStatics.ExecuteTimedRegion(() => operationResult.NumberOfBytesTransferred = downloadDataPackage(packageZipFilePath));
                }
            }

            deleteOldFiles(downloadedPackagesFolder, InstallationTypeElements is LiveInstallationElements);
            return(packageZipFilePath);
        }
        void Operation.Execute(Installation genericInstallation, OperationResult operationResult)
        {
            var installation = genericInstallation as DevelopmentInstallation;

            var logicPackagesFolderPath = EwlStatics.CombinePaths(installation.GeneralLogic.Path, "Logic Packages");

            IoMethods.DeleteFolder(logicPackagesFolderPath);

            // Set up the main (build) object in the build message.
            var build = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build();

            build.SystemName      = installation.ExistingInstallationLogic.RuntimeConfiguration.SystemName;
            build.SystemShortName = installation.ExistingInstallationLogic.RuntimeConfiguration.SystemShortName;
            build.MajorVersion    = installation.CurrentMajorVersion;
            build.BuildNumber     = installation.NextBuildNumber;
            build.LogicSize       = ConfigurationLogic.NDependIsPresent && !installation.DevelopmentInstallationLogic.SystemIsEwl
                                                  ? GetLogicSize.GetNDependLocCount(installation, false) as int?
                                                  : null;
            var serverSideLogicFolderPath = EwlStatics.CombinePaths(logicPackagesFolderPath, "Server Side Logic");

            packageWebApps(installation, serverSideLogicFolderPath);
            packageWindowsServices(installation, serverSideLogicFolderPath);
            packageServerSideConsoleApps(installation, serverSideLogicFolderPath);
            packageGeneralFiles(installation, serverSideLogicFolderPath, true);
            build.ServerSideLogicPackage             = ZipOps.ZipFolderAsByteArray(serverSideLogicFolderPath);
            operationResult.NumberOfBytesTransferred = build.ServerSideLogicPackage.LongLength;

            // Set up the client side application object in the build message, if necessary.
            if (installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject != null)
            {
                build.ClientSideApp              = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.ClientSideAppType();
                build.ClientSideApp.Name         = installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.name;
                build.ClientSideApp.AssemblyName = installation.DevelopmentInstallationLogic.DevelopmentConfiguration.clientSideAppProject.assemblyName;
                var clientSideAppFolder = EwlStatics.CombinePaths(logicPackagesFolderPath, "Client Side Application");
                packageClientSideApp(installation, clientSideAppFolder);
                packageGeneralFiles(installation, clientSideAppFolder, false);
                build.ClientSideApp.Package = ZipOps.ZipFolderAsByteArray(clientSideAppFolder);
                operationResult.NumberOfBytesTransferred += build.ClientSideApp.Package.LongLength;
            }

            // Set up the list of installation objects in the build message.
            build.Installations = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Build.InstallationsType();
            foreach (var installationConfigurationFolderPath in
                     Directory.GetDirectories(
                         EwlStatics.CombinePaths(
                             installation.ExistingInstallationLogic.RuntimeConfiguration.ConfigurationFolderPath,
                             InstallationConfiguration.InstallationConfigurationFolderName,
                             InstallationConfiguration.InstallationsFolderName)))
            {
                if (Path.GetFileName(installationConfigurationFolderPath) != InstallationConfiguration.DevelopmentInstallationFolderName)
                {
                    var buildMessageInstallation = new InstallationSupportUtility.RsisInterface.Messages.BuildMessage.Installation();

                    // Do not perform schema validation since the schema file on disk may not match this version of the ISU.
                    var installationConfigurationFile =
                        XmlOps.DeserializeFromFile <InstallationStandardConfiguration>(
                            EwlStatics.CombinePaths(installationConfigurationFolderPath, InstallationConfiguration.InstallationStandardConfigurationFileName),
                            false);

                    buildMessageInstallation.Id                 = installationConfigurationFile.rsisInstallationId;
                    buildMessageInstallation.Name               = installationConfigurationFile.installedInstallation.name;
                    buildMessageInstallation.ShortName          = installationConfigurationFile.installedInstallation.shortName;
                    buildMessageInstallation.IsLiveInstallation =
                        installationConfigurationFile.installedInstallation.InstallationTypeConfiguration is LiveInstallationConfiguration;
                    buildMessageInstallation.ConfigurationPackage = ZipOps.ZipFolderAsByteArray(installationConfigurationFolderPath);
                    build.Installations.Add(buildMessageInstallation);
                    operationResult.NumberOfBytesTransferred += buildMessageInstallation.ConfigurationPackage.LongLength;
                }
            }

            if (installation.DevelopmentInstallationLogic.SystemIsEwl)
            {
                build.NuGetPackages = packageEwl(installation, logicPackagesFolderPath);
            }

            var recognizedInstallation = installation as RecognizedDevelopmentInstallation;

            if (recognizedInstallation == null)
            {
                return;
            }

            build.SystemId = recognizedInstallation.KnownSystemLogic.RsisSystem.Id;

            operationResult.TimeSpentWaitingForNetwork = EwlStatics.ExecuteTimedRegion(
                delegate {
                using (var memoryStream = new MemoryStream()) {
                    // Understand that by doing this, we are not really taking advantage of streaming, but at least it will be easier to do it the right way some day (probably by implementing our own BuildMessageStream)
                    XmlOps.SerializeIntoStream(build, memoryStream);
                    memoryStream.Position = 0;

                    ConfigurationLogic.ExecuteIsuServiceMethod(
                        channel => channel.UploadBuild(new BuildUploadMessage {
                        AuthenticationKey = ConfigurationLogic.AuthenticationKey, BuildDocument = memoryStream
                    }),
                        "build upload");
                }
            });
        }