public void InstallPackage(string fastPackageReference) { var requirements = ParseReference(fastPackageReference); try { Install(requirements); SelfUpdateCheck(); } catch (UnsuitableInstallBaseException ex) { string installLocation = ZeroInstallInstance.FindOther(ex.NeedsMachineWide); if (installLocation == null) { if (Handler.Ask(Resources.AskDeployZeroInstall + Environment.NewLine + ex.Message, defaultAnswer: true, alternateMessage: ex.Message)) { installLocation = DeployInstance(ex.NeedsMachineWide); } else { return; } } // Since we cannot another copy of Zero Install from a different location into the same AppDomain, simply pretend we are running from a different source Locations.OverrideInstallBase(installLocation); Install(requirements); } }
private void MainForm_Shown(object sender, EventArgs e) { WindowsUtils.RegisterApplicationRestart(_machineWide ? "--restart --machine" : "--restart"); UpdateAppListAsync(); _tileManagement.LoadCachedCatalog(); LoadCatalogAsync(); bool firstRun = OnFirstRun(); if (_tileManagement.AppList.Entries.Count == 0) { if (firstRun) { using var dialog = new IntroDialog(); dialog.ShowDialog(this); } // Show catalog automatically if AppList is empty tabControlApps.SelectTab(tabPageCatalog); } if (ZeroInstallInstance.IsRunningFromCache) { if (ZeroInstallInstance.FindOther() == null) { deployTimer.Enabled = true; } } else { selfUpdateWorker.RunWorkerAsync(); } }
/// <summary> /// Runs the removal process. /// </summary> /// <exception cref="UnauthorizedAccessException">Access to a resource was denied.</exception> /// <exception cref="IOException">An IO operation failed.</exception> public void Remove() { var targetManifest = LoadManifest(TargetDir); #if NETFRAMEWORK if (MachineWide) { ServiceStop(); ServiceUninstall(); NgenRemove(); } #endif try { if (WindowsUtils.IsWindows) { TargetMutexAcquire(); } using (var clearDir = new ClearDirectory(TargetDir, targetManifest, Handler) { NoRestart = true }) { clearDir.Stage(); #if NETFRAMEWORK DeleteServiceLogFiles(); #endif if (Portable) { File.Delete(Path.Combine(TargetDir, Locations.PortableFlagName)); } clearDir.Commit(); } if (!Portable && WindowsUtils.IsWindows) { DesktopIntegrationRemove(); ZeroInstallInstance.UnregisterLocation(MachineWide); } } finally { if (WindowsUtils.IsWindows) { TargetMutexRelease(); } } }
/// <summary> /// Runs the deployment process. /// </summary> /// <param name="libraryMode">Deploy Zero Install as a library for use by other applications without its own desktop integration.</param> /// <exception cref="UnauthorizedAccessException">Access to a resource was denied.</exception> /// <exception cref="IOException">An IO operation failed.</exception> public void Deploy(bool libraryMode = false) { if (Portable && libraryMode) { throw new ArgumentException(string.Format(Resources.CannotUseOptionsTogether, "--portable", "--library"), nameof(libraryMode)); } var newManifest = LoadManifest(Locations.InstallBase); var oldManifest = LoadManifest(TargetDir); try { MutexAcquire(); if (!FileUtils.PathEquals(TargetDir, Locations.InstallBase)) { if (MachineWide) { ServiceStop(); } using var clearDir = new ClearDirectory(TargetDir, oldManifest, Handler); using var deployDir = new DeployDirectory(Locations.InstallBase, newManifest, TargetDir, Handler); deployDir.Stage(); clearDir.Stage(); if (Portable) { FileUtils.Touch(Path.Combine(TargetDir, Locations.PortableFlagName)); } deployDir.Commit(); clearDir.Commit(); } if (!Portable) { if (!libraryMode) { DesktopIntegrationApply(newManifest.TotalSize); } ZeroInstallInstance.RegisterLocation(TargetDir, MachineWide, libraryMode); RemoveOneGetBootstrap(); } MutexRelease(); if (MachineWide) { NgenApply(); if (ServiceInstall()) { ServiceStart(); } TaskSchedulerApply(libraryMode); } } catch { MutexRelease(); throw; } }
private void selfUpdateWorker_DoWork(object sender, DoWorkEventArgs e) { e.Result = ZeroInstallInstance.SilentUpdateCheck(); }