Пример #1
0
        /// <summary>
        /// Given the path to a zip file containing an update, executes the update process.
        /// </summary>
        /// <param name="zipFilePath">Zip file path.</param>
        public static async void ExecuteUpdate(string zipFilePath)
        {
            string scriptFileName = await UpdateMethods.ExtractPowershellScript().ConfigureAwait(false);

            Process.Start(new ProcessStartInfo
            {
                WorkingDirectory = Path.GetTempPath(),
                UseShellExecute  = false,
                FileName         = "powershell.exe",
                Arguments        = $"-ExecutionPolicy Bypass -File \"{Path.GetFileName(scriptFileName)}\" {Process.GetCurrentProcess().Id} \"{Path.GetFileName(zipFilePath)}\"",
            }).WaitForExit();
        }
Пример #2
0
        /// <summary>
        /// Fetches the latest 2.x release.
        /// </summary>
        /// <param name="cancellationToken">Optionally used to propagate cancellation requests.</param>
        /// <returns>Information related to a release. Returns <see langword="null"/> if not found or an error occurs.</returns>
        public static async Task <IReleaseInfo?> FetchLatest2xReleaseAsync(CancellationToken cancellationToken = default)
        {
            try
            {
                foreach (Tag tag in await UpdateMethods.FetchTagsAsync(cancellationToken).ConfigureAwait(false))
                {
                    if (tag.Version.Major != 2)
                    {
                        continue;
                    }
                    Release?release = await UpdateMethods.FetchReleaseAsync(tag.Name, cancellationToken).ConfigureAwait(false);

                    if (release != null && release.HasUpdateAsset)
                    {
                        return(release);
                    }
                }
            }
            catch
            {
            }
            return(default);