Exemplo n.º 1
0
        private void LoadConfiguration(BuildForm bf)
        {
            _objConfig = new InstallerConfig(SparkGlobals.BuildConfigPath);
            _objConfig.Load();
            _objConfig.BuildFileList();

            if (_objConfig.Options.GetOption(InstallOption.AppGuid) == null)
            {
                Globals.Throw("The install option 'AppGuid' is required. Please add this option to the input configuration file.");
            }

            //Attempt to parse GUID - if it is invalid an exception will throw.
            ProgramInfo.TryParseGuidToUninstallGuid(_objConfig.Options.GetOption(InstallOption.AppGuid).Value);

            if (_objConfig.Options.GetOption(InstallOption.DisplayName) == null)
            {
                Globals.Throw("The install option 'DisplayName' is required. Please add this option to the input configuration file.");
            }

            Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedFiles + " files.");
            Globals.Logger.LogInfo("Excluded " + _objConfig.NumExcludedDirectories + " directories.");
            Globals.Logger.LogInfo("Packaging " + _objConfig.GetFiles().Count + " total files.");

            _objFileTable = new InstallerFileTable(_objConfig);
            bf.Progress(0.01);
        }
Exemplo n.º 2
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();
            }
        }