/// <summary> /// Returns the overridable release location /// </summary> /// <param name="config">The config that allows override of the default settings</param> /// <returns>The release location</returns> internal static string GetReleaseLocation(OverridableConfig config) { // The BuildConstants class is generated at build time, meaning that it's possible // for BuildConstants.DefaultReleaseLocation to be empty. If this occurs, we'll use // the assembly's location as the default release location string defaultReleaseLocation = (BuildConstants.DefaultReleaseLocation.Length > 0) ? BuildConstants.DefaultReleaseLocation : Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); return(config.GetConfigSetting(ReleaseLocation, defaultReleaseLocation)); }
private AutoUpdateOption Initialize() { // Do NOT use anything that calls WaitForInitializationToComplete in this // method, or you may create a deadlock condition try { OverridableConfig config = new OverridableConfig(ConfigFile); _releaseLocation = UpdateMethods.GetReleaseLocation(config); _metaMSISettings = UpdateMethods.ExtractMSIInfo(_releaseLocation); if (_metaMSISettings == null) { // silently ignore System.Diagnostics.Trace.WriteLine($"Unable to get update info from meta file at {_releaseLocation}"); return(AutoUpdateOption.Unknown); } _installerLocation = _metaMSISettings.GetMSIPathSafely(_releaseLocation); #pragma warning disable CA1806 // Do not ignore method results Version.TryParse(_metaMSISettings.Version, out _latestVersion); Version.TryParse(_metaMSISettings.MinimumVersion, out _minimumVersion); Version.TryParse(UpdateMethods.GetInstalledProductVersion(), out _installedVersion); #pragma warning restore CA1806 // Do not ignore method results if (_installedVersion != null && _latestVersion != null && _minimumVersion != null) { if (_latestVersion < _minimumVersion) { return(AutoUpdateOption.Unknown); } if (_installedVersion < _minimumVersion) { return(AutoUpdateOption.RequiredUpgrade); } else if (_installedVersion < _latestVersion) { return(AutoUpdateOption.OptionalUpgrade); } return(AutoUpdateOption.Current); } } catch (Exception e) { e.ReportException(); } return(AutoUpdateOption.Unknown); // Our fallback value if we can't prove a better option }