public void Install(IEnumerable <ComponentVersion> components, string exe_path = null, Action <ComponentVersion> component_installed = null) { exe_path = _GetExePath(exe_path); _Installer.ChangeExePath(exe_path); _Logger.Info($"OPERATION: Install. Target: {exe_path}"); var used_components = new HashSet <ETGModComponent>(); var gungeon_version = Autodetector.GetVersionIn(exe_path); if (!Options.HasFlag(InstallerOptions.ForceBackup)) { _Installer.Restore(); } _Installer.Backup(Options.HasFlag(InstallerOptions.ForceBackup)); foreach (var pair in components) { using (var build = _Downloader.Download(pair.Version)) { var installable = new Installer.InstallableComponent(pair.Component, pair.Version, build); if (!Options.HasFlag(InstallerOptions.SkipVersionChecks)) { try { installable.ValidateGungeonVersion(gungeon_version); } catch (Installer.InstallableComponent.VersionMismatchException e) { throw new InstallationFailedException(e.Message); } } _Installer.InstallComponent(installable, Options.HasFlag(InstallerOptions.LeavePatchDLLs)); if (component_installed != null) { component_installed.Invoke(pair); } } } _Logger.Info($"OPERATION COMPLETED SUCCESSFULLY"); }
public InstallerFrontend(InstallerOptions options = InstallerOptions.None) { var settings = Settings.Instance; if (settings.SkipVersionChecks) { Options |= InstallerOptions.SkipVersionChecks; } if (settings.ForceHTTP) { Options |= InstallerOptions.HTTP; } if (settings.LeavePatchDLLs) { Options |= InstallerOptions.LeavePatchDLLs; } if (settings.ForceBackup) { Options |= InstallerOptions.ForceBackup; } if (settings.Offline) { Options |= InstallerOptions.Offline; } Options |= options; _Downloader = new Downloader(force_http: Options.HasFlag(InstallerOptions.HTTP), offline: Options.HasFlag(InstallerOptions.Offline)); _Installer = new Installer(_Downloader, exe_path: null); var cache_dir = Path.Combine(Settings.SettingsDir, "Unity"); var sevenz_path = Settings.Instance.SevenZipPath; _DebugConverter = new DebugConverter(cache_dir, _Installer, sevenz_path); Environment.SetEnvironmentVariable("MONOMOD_DEBUG_FORMAT", "MDB"); foreach (var ent in settings.CustomComponentFiles) { LoadComponentsFile(ent); } }