Пример #1
0
        /// <summary>
        /// Get info web version
        /// </summary>
        /// <param name="appName"></param>
        /// <returns></returns>
        public static (string Info, bool IsNewVersion, string BrowserDownloadUrl) GetInfo(string appName)
        {
            var info         = UpdateHelper.GetInfoLastReleaseAssetFromGitHub(appName);
            var currVer      = ShellHelper.GetCurrentVersionApp();
            var isNewVersion = info.Version.ToString() != currVer;
            var msg          = isNewVersion ?
                               $"New version available: {info.Version}" :
                               "You are already at the latest version";

            return($@"===== In execution release:
Version:       {currVer}

===== Last release:
Version:       {info.Version} 
Published At:  {info.PublishedAt} 
Download Url:  {info.BrowserDownloadUrl} 
Release Notes: {info.ReleaseNotes}

{msg}", isNewVersion, info.BrowserDownloadUrl);
        }
Пример #2
0
        /// <summary>
        /// Execute console application.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static int ExecuteConsoleApp(this CommandLineApplication app, string[] args)
        {
            //execute command
            try
            {
                Version webVersion = null;

                //check new version available
                var taskInfo = new Task(() =>
                {
                    try
                    {
                        var version = UpdateHelper.GetInfoLastReleaseAssetFromGitHub(app.Name).Version;
                        if (version.ToString() != GetCurrentVersionApp())
                        {
                            webVersion = version;
                        }
                    }
                    catch { }
                });
                taskInfo.Start();

                var ret = app.Execute(args);

                taskInfo.Wait(1000);

                if ((app.OptionHelp.HasValue() || app.OptionVersion.HasValue()) &&
                    webVersion != null &&
                    webVersion > new Version(GetCurrentVersionApp()))
                {
                    app.Out.WriteLine("====================================");
                    app.Out.WriteLine($"New version available: {webVersion}");
                    app.Out.WriteLine("====================================");
                }

                return(ret);
            }
            catch (Exception ex)
            {
                if (ex is CommandParsingException || ex is ApplicationException) //|| ex is ArgumentException)
                {
                    app.Out.WriteLine(ex.Message);
                }
                else
                {
                    app.Out.WriteLine("================ EXCEPTION ================ ");
                    app.Out.WriteLine(ex.GetType().FullName);
                    app.Out.WriteLine(ex.Message);
                    app.Out.WriteLine(ex.StackTrace);
                }

                if (app.DebugIsActive())
                {
                    app.Out.WriteLine("================ EXCEPTION ================ ");
                    app.Out.WriteLine(ex.GetType().FullName);
                    app.Out.WriteLine(ex.Message);
                    app.Out.WriteLine(ex.StackTrace);
                }

                return(1);
            }
        }
Пример #3
0
        /// <summary>
        /// Finish upgrade
        /// </summary>
        /// <param name="fileNameNew"></param>
        public static void UpgradeFinish(string fileNameNew)
        {
            var fileNameApp = UpdateHelper.GetFileNameAppFromNew(fileNameNew);

            File.Copy(fileNameNew, fileNameApp, true);
        }