Beispiel #1
0
        public void LoadOptions()
        {
            Globals.Logger.LogInfo("Extracting Install Options");

            //Use a dummy to get the options table.
            InstallerBinary dummy = new InstallerBinary();

            _objOptions = new InstallOptions();

            try
            {
                dummy.OpenStream();
                _objOptions.Deserialize(dummy);
            }
            catch (Exception ex)
            {
                Globals.Logger.LogInfo("Exception opening install options: " + ex.ToString());

                throw ex;
            }
            finally
            {
                dummy.CloseStream();
            }

            dummy = null;
        }
Beispiel #2
0
        public string AppGuid;                // NOTE: this may NOT represent the correct Guid.

        public ProgramInfo(InstallOptions objOptions)
        {
            DisplayName        = objOptions.GetOptionValueOrDefault(InstallOption.DisplayName);
            InstallLocation    = objOptions.GetOptionValueOrDefault(InstallOption.InstallLocation);
            Publisher          = objOptions.GetOptionValueOrDefault(InstallOption.Publisher);
            DisplayIcon        = objOptions.GetOptionValueOrDefault(InstallOption.DisplayIcon);
            ApplicationVersion = objOptions.GetOptionValueOrDefault(InstallOption.ApplicationVersion);
            DisplayVersion     = objOptions.GetOptionValueOrDefault(InstallOption.DisplayVersion);
            URLInfoAbout       = objOptions.GetOptionValueOrDefault(InstallOption.URLInfoAbout);
            Contact            = objOptions.GetOptionValueOrDefault(InstallOption.Contact);
            AppGuid            = objOptions.GetOptionValueOrDefault(InstallOption.AppGuid);
        }
Beispiel #3
0
        public string WriteUninstaller(InstallOptions objOptions, string strInstallRoot)
        {
            // ** Add the installer to the install directory so we can uninstall.
            string uninstallFileName = System.IO.Path.Combine(strInstallRoot, "Uninstall.exe");

            Globals.Logger.LogInfo("Writing File " + uninstallFileName);

            InstallerBuilder builder = new InstallerBuilder();

            builder.BuildUninstaller(this, objOptions, uninstallFileName);

            //InstalledFiles.Add(uninstallFileName);
            return(uninstallFileName);
        }
Beispiel #4
0
        private void ExecuteUninstall()
        {
            InstallerFileTable objTable   = null;
            InstallerBinary    objBinary  = null;
            InstallOptions     objOptions = null;

            InstallState = Installer.InstallState.Uninstalling;

            //TODO: uninstaller has to store options AND uninstall table.
            try
            {
                objBinary = new InstallerBinary();
                objBinary.OpenStream();
                objOptions = new InstallOptions();
                objOptions.Deserialize(objBinary);
                objTable = new InstallerFileTable(this);
                objTable.Deserialize(objBinary);
                objBinary.CloseStream();

                ProgramInfo objInfo = new ProgramInfo(objOptions);

                string strInstallRoot = objOptions.GetOptionValueOrDefault(InstallOption.UninstallFolderRoot_Uninstaller_Only);
                if (!System.IO.Directory.Exists(strInstallRoot))
                {
                    Globals.Logger.LogError("Fatal Error: The original install directory '"
                                            + strInstallRoot
                                            + "' does not exist, or was not packed in the uninstaller binary.", true, true);
                }

                RollbackOrUninstall(objTable, strInstallRoot, 0.0);

                RemoveRegistryKeys(objInfo);

                InstallState = Installer.InstallState.Successful;
            }
            catch (Exception ex)
            {
                InstallState = Installer.InstallState.Canceled;
                InstallErrors.Add("Error: " + ex.ToString());
                Globals.Logger.LogError(ex.ToString(), false, true);
            }
            finally
            {
                EndUninstall();
            }
        }
        /*
         * See InstallerManager for file format.
         *
         */
        public void BuildUninstaller(InstallerFileTable ft, InstallOptions opt, string outputFileName)
        {
            //**Do not modify the filename.
            InstallerBinary objBinary = new InstallerBinary();

            objBinary.OpenStream();
            objBinary.CloseStream();

            byte[] temp;
            temp   = objBinary.GetInstallerBinary();
            _final = BufferUtils.Combine(_final, temp);
            temp   = InstallerBinary.GetTokenBytes();
            _final = BufferUtils.Combine(_final, temp);
            temp   = opt.Serialize();
            _final = BufferUtils.Combine(_final, temp);
            temp   = ft.Serialize(); // ** Ft is already built.  Do not call Build()
            _final = BufferUtils.Combine(_final, temp);

            FileUtils.WriteBytesViaStream(outputFileName, _final);
        }
Beispiel #6
0
        private void ExecuteInstallation()
        {
            DisplayMsg("Beginning Installation");
            InstallState = InstallState.Installing;
            InstallerFileTable objTable = null;

            string strInstallRoot = CreateInstallRoot();

            if (string.IsNullOrEmpty(strInstallRoot))
            {
                return; // error
            }
            double dblProgressBeforeCopy = 0;

            try
            {
                DisplayMsg("Creating install dir " + strInstallRoot);
                if (!System.IO.Directory.Exists(strInstallRoot))
                {
                    System.IO.Directory.CreateDirectory(strInstallRoot);
                }

                // - Do work
                InstallerBinary objBinary;
                DisplayMsg("Creating binary");
                objBinary = new InstallerBinary();
                objBinary.OpenStream();

                //**Read past the install options section.  Note this
                // is NOT used
                DisplayMsg("Reading Dummy Options");
                InstallOptions dummy = new InstallOptions();
                dummy.Deserialize(objBinary);

                //Validate appliation GUID for uninstall.
                InstallOption guidOpt = GetOption(InstallOption.AppGuid);
                if (guidOpt == null)
                {
                    Globals.Throw("Could not install.  Appliation GUID was not specified in install options.");
                }
                else
                {
                    ProgramInfo.TryParseGuidToUninstallGuid(guidOpt.Value);
                }

                DisplayMsg("Creating Program Info");
                ProgramInfo objInfo = new ProgramInfo(_objOptions);

                DisplayMsg("Reading File Table");
                objTable = new InstallerFileTable(this);
                objTable.Deserialize(objBinary);

                _dblProgress = dblProgressBeforeCopy = 0.5;

                DisplayMsg("Unpacking Files");
                objTable.UnpackFiles(
                    objBinary,
                    strInstallRoot,
                    ref _dblProgress,
                    _installerCancellationToken.Token,
                    ref _strCurrentFile
                    );

                objBinary.CloseStream();

                CreateAppRegistryKeys(objInfo, strInstallRoot);
                CreateUninstaller(objInfo, objBinary, objTable, strInstallRoot);
            }
            catch (Exception ex)
            {
                InstallState = Installer.InstallState.Canceled;
                InstallErrors.Add("Error: " + ex.ToString());
                Globals.Logger.LogError(ex.ToString(), false, true);
                RollbackOrUninstall(objTable, strInstallRoot, dblProgressBeforeCopy);
            }
            finally
            {
                EndInstallation();
            }
        }