protected override void Run()
        {
            base.Run();

            var session = Connection.Session;

            var url = session.Url;
            Uri uri = new Uri(url);

            var appFolder = Path.Combine(m_applianceDirectory, m_applianceFileName);
            var appFile   = string.Format("{0}.ovf", m_applianceFileName);

            if (!Directory.Exists(appFolder))
            {
                Directory.CreateDirectory(appFolder);
            }
            PercentComplete = 5;

            Description = Messages.EXPORTING_VMS;
            EnvelopeType env;

            try
            {
                m_transportAction = new XenOvfTransport.Export(uri, session)
                {
                    UpdateHandler     = UpdateHandler,
                    ShouldVerifyDisks = m_shouldVerify,
                    Cancel            = Cancelling                                  //in case the Cancel button has already been pressed
                };
                m_transportAction.SetTvmNetwork(m_networkUuid, m_isTvmIpStatic, m_tvmIpAddress, m_tvmSubnetMask, m_tvmGateway);
                env             = (m_transportAction as XenOvfTransport.Export).Process(appFolder, m_applianceFileName, (from VM vm in m_vmsToExport select vm.uuid).ToArray());
                PercentComplete = 60;
            }
            catch (OperationCanceledException)
            {
                throw new CancelledException();
            }

            foreach (var eula in m_eulas)
            {
                if (Cancelling)
                {
                    throw new CancelledException();
                }
                Description = Messages.ADDING_EULAS;
                OVF.AddEula(env, eula);
            }

            if (Cancelling)
            {
                throw new CancelledException();
            }

            var ovfPath = Path.Combine(appFolder, appFile);

            Description = String.Format(Messages.CREATING_FILE, appFile);
            OVF.SaveAs(env, ovfPath);
            PercentComplete = 70;

            if (Cancelling)
            {
                throw new CancelledException();
            }

            if (m_signAppliance)
            {
                Description = Messages.SIGNING_APPLIANCE;
                OVF.Sign(m_certificate, appFolder, appFile);
            }
            else if (m_createManifest)
            {
                Description = Messages.CREATING_MANIFEST;
                OVF.Manifest(appFolder, appFile);
            }

            PercentComplete = 90;

            if (Cancelling)
            {
                throw new CancelledException();
            }

            if (m_createOVA)
            {
                Description = String.Format(Messages.CREATING_FILE, String.Format("{0}.ova", m_applianceFileName));
                OVF.ConvertOVFtoOVA(appFolder, appFile, m_compressOVFfiles);
            }
            else if (m_compressOVFfiles)
            {
                Description  = Messages.COMPRESSING_FILES;
                m_compressor = new OvfCompressor {
                    CancelCompression = Cancelling
                };                                                                                   //in case the Cancel button has already been pressed}

                try
                {
                    m_compressor.CompressOvfFiles(ovfPath, "GZip");
                }
                catch (OperationCanceledException)
                {
                    throw new CancelledException();
                }
            }

            PercentComplete = 100;
            Description     = Messages.COMPLETED;
        }
        protected override void RunCore()
        {
            log.Info($"Exporting VMs to package {m_applianceFileName}");

            var appFolder = Path.Combine(m_applianceDirectory, m_applianceFileName);
            var appFile   = string.Format("{0}.ovf", m_applianceFileName);

            if (!Directory.Exists(appFolder))
            {
                Directory.CreateDirectory(appFolder);
            }

            var envList = new List <EnvelopeType>();

            for (int i = 0; i < m_vmsToExport.Count; i++)
            {
                var vm = m_vmsToExport[i];
                CheckForCancellation();
                Description = string.Format(Messages.EXPORTING_VM_PREPARE, vm.Name());

                int curVm = i;
                void UpdatePercentage(float x)
                {
                    PercentComplete = (int)((curVm + x) * 80 / m_vmsToExport.Count);
                }

                try
                {
                    var envelope = Export(appFolder, vm, UpdatePercentage);
                    envList.Add(envelope);
                    PercentComplete = (i + 1) * 80 / m_vmsToExport.Count;
                }
                catch (OperationCanceledException)
                {
                    throw new CancelledException();
                }
            }

            EnvelopeType env = OVF.Merge(envList, m_applianceFileName);

            PercentComplete = 80;

            foreach (var eula in m_eulas)
            {
                CheckForCancellation();
                Description = Messages.ADDING_EULAS;
                OVF.AddEula(env, eula);
            }

            CheckForCancellation();
            var ovfPath = Path.Combine(appFolder, appFile);

            OVF.SaveAs(env, ovfPath);
            PercentComplete = 85;

            CheckForCancellation();

            if (m_createOVA)
            {
                ManifestAndSign(env, appFolder, appFile);
                PercentComplete = 90;
                log.Info($"Archiving OVF package {m_applianceFileName} into OVA");
                Description = string.Format(Messages.CREATING_OVA_FILE, string.Format("{0}.ova", m_applianceFileName));
                OVF.ConvertOVFtoOVA(env, ovfPath, CheckForCancellation, m_compressOVFfiles);
            }
            else if (m_compressOVFfiles)
            {
                log.Info($"Compressing package {m_applianceFileName}");
                Description = Messages.COMPRESSING_FILES;
                OVF.CompressFiles(env, ovfPath, CompressionFactory.Type.Gz, CheckForCancellation);
                PercentComplete = 95;
                ManifestAndSign(env, appFolder, appFile);
            }
            else
            {
                ManifestAndSign(env, appFolder, appFile);
            }

            PercentComplete = 100;
            Description     = Messages.COMPLETED;
        }