public string ReplaceValueVariables(string strValue) { if (strValue.Contains(InstallerVariable.ProgramFiles)) { //**Also - Environment.GetEnvironmentVariable("ProgramFiles"); - returns x86 program files. string strProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); strValue = strValue.Replace(InstallerVariable.ProgramFiles, strProgramFiles); } if (strValue.Contains(InstallerVariable.ProgramFilesX86)) { string strProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86); strValue = strValue.Replace(InstallerVariable.ProgramFiles, strProgramFiles); } if (strValue.Contains(InstallerVariable.Desktop)) { string strProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); strValue = strValue.Replace(InstallerVariable.ProgramFiles, strProgramFiles); } if (strValue.Contains(InstallerVariable.SystemRoot)) { string strProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.Windows); strValue = strValue.Replace(InstallerVariable.ProgramFiles, strProgramFiles); } if (strValue.Contains(InstallerVariable.InstallDir)) { InstallOption opt = GetOption(InstallOption.InstallLocation); if (opt == null) { Globals.Throw("Could not get install location. Doesn't seem to have been set. (0101984)"); } strValue = strValue.Replace(InstallerVariable.InstallDir, opt.Value); } return(strValue); }
private string CreateInstallRoot() { string strInstallRoot = string.Empty; try { // - Checks Globals.Logger.LogInfo("Creating Root"); InstallOption location = GetOption(InstallOption.InstallLocation); if (location == null) { Globals.Throw("Install location was not set."); } strInstallRoot = ReplaceValueVariables(location.Value); Globals.Logger.LogInfo("Creating Root Dir.."); if (!System.IO.Directory.Exists(strInstallRoot)) { System.IO.Directory.CreateDirectory(strInstallRoot); } } catch (Exception ex) { InstallErrors.Add("Error: " + ex.ToString()); Globals.Logger.LogError(ex.ToString()); return(""); } return(strInstallRoot); }
public InstallOption AddOrReplaceOption(string key, string value) { InstallOption opt = new InstallOption(key, value); _objOptions.AddOrReplaceOption(opt); return(opt); }
public string GetOptionValueOrDefault(string key) { InstallOption opt = GetOption(key); if (opt == null) { return(string.Empty); } return(opt.Value); }
public void Deserialize(InstallerBinary objBinary) { Int64 count = objBinary.ReadInt64(); for (Int64 iOption = 0; iOption < count; iOption++) { InstallOption opt = InstallOption.Deserialize(objBinary); _lstInstallOptions.Add(opt); } }
private void UninstallOptions_Load(object sender, EventArgs e) { Installer.InstallOption opt = _objForm.GetInstaller().GetOption(Installer.InstallOption.DisplayName); if (opt != null) { _strProgramName = opt.Value; } _optUninstall.Text = "Uninstall " + _strProgramName; _optRepair.Text = "Repair " + _strProgramName; }
public void AddOrReplaceOption(InstallOption opt) { InstallOption found = GetOption(opt.Key); if (found != null) { found.Value = opt.Value; } else { _lstInstallOptions.Add(opt); } }
public OptionsControl(MainForm objForm) { InitializeComponent(); Init(objForm); _grpOptions.Visible = false; ResizeItems(); Installer.InstallOption opt = objForm.GetInstaller().GetOption(Installer.InstallOption.DefaultDirectory); if (opt != null) { opt.Value = objForm.GetInstaller().ReplaceValueVariables(opt.Value); _txtInstallDir.Text = opt.Value; } }
private void button1_Click(object sender, EventArgs e) { if (_optUninstall.Checked == true) { Installer.InstallOption opt = _objForm.GetInstaller().GetOption(Installer.InstallOption.DisplayName); DialogResult res = System.Windows.Forms.MessageBox.Show( "Are you sure you want to uninstall " + _strProgramName + "?", "Confirm Uninstall", MessageBoxButtons.YesNo); if (res == System.Windows.Forms.DialogResult.Yes) { _objForm.SwapView(InstallerViewType.Progress); } } }
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(); } }
public InstallOption GetOption(string key) { InstallOption opt = _lstInstallOptions.Where(x => x.Key.Equals(key)).FirstOrDefault(); return(opt); }