栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > .Net

.Net自动更新程序GeneralUpdate,适用于wpf,winfrom,控制台应用

.Net 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

.Net自动更新程序GeneralUpdate,适用于wpf,winfrom,控制台应用

GeneralUpdate

GeneralUpdate是基于.net framwork4.5.2开发的一款(c/s应用)自动升级程序。

第一个版本叫Autoupdate(原博客: WPF自动更新程序)有人会奇怪为什么会改名称,稍微解释一下是因为在nuget上有重名的项目再者就是新版本更新功能不仅限于wpf程序的更新。

将更新的核心部分抽离出来方便应用于多种项目当中目前适用于wpf,控制台应用,winfrom。相比以前更方便的是不需要在过分关注源码可直接通过nuget直接使用。

如果有任何使用问题可以在Github的issues上进行提问我会每周统一找时间解决并解答bug或者问题。或者联系文章末尾的联系方式会有人解答。

如何使用:

Gitee(码云)地址:https://gitee.com/Juster-zhu/GeneralUpdate

Nuget地址:https://www.nuget.org/packages/GeneralUpdate.Core/

GitHub地址: https://github.com/WELL-E/AutoUpdater GeneralUpdate版本在 Branch:Autoupdate2。

issues:https://github.com/WELL-E/AutoUpdater/issues

运行截图:

快速启动:

#region Launch1

        args = new string[6] {
            "0.0.0.0",
            "1.1.1.1",
            "https://github.com/WELL-E",
             "http://192.168.50.225:7000/update.zip",
             @"E:PlatformPath",
            "509f0ede227de4a662763a4abe3d8470",
             };

        GeneralUpdateBootstrap bootstrap = new GeneralUpdateBootstrap();//自动更新引导类
        bootstrap.DownloadStatistics += OnDownloadStatistics;//下载进度通知事件
        bootstrap.ProgressChanged += OnProgressChanged;//更新进度通知事件
        bootstrap.Strategy().//注册策略,可自定义更新流程
            Option(UpdateOption.Format, "zip").//指定更新包的格式,目前只支持zip
            Option(UpdateOption.MainApp, "your application name").//指定更新完成后需要启动的主程序名称不需要加.exe直接写名称即可
            RemoteAddress(args).//这里的参数保留了之前的参数数组集合
            Launch();//启动更新

        #endregion

        #region Launch2

        

        //GeneralUpdateBootstrap bootstrap2 = new GeneralUpdateBootstrap();
        //bootstrap2.DownloadStatistics += OnDownloadStatistics;
        //bootstrap2.ProgressChanged += OnProgressChanged;
        //bootstrap2.Strategy().
        //    Option(UpdateOption.Format, "zip").
        //    Option(UpdateOption.MainApp, "").
        //    RemoteAddress(@"https://api.com/GeneralUpdate?version=1.0.0.1").//指定更新地址
        //    Launch();

        #endregion

    private static void OnProgressChanged(object sender, ProgressChangedEventArgs e)
    {
        if (e.Type == ProgressType.Updatefile)
        {
            var str = $"当前更新第:{e.ProgressValue}个,更新文件总数:{e.TotalSize}";
            Console.WriteLine(str);
        }

        if (e.Type == ProgressType.Done)
        {
            Console.WriteLine("更新完成");
        }
    }

    private static void OnDownloadStatistics(object sender, DownloadStatisticsEventArgs e)
    {
        Console.WriteLine($"下载速度:{e.Speed},剩余时间:{e.Remaining.Minute}:{e.Remaining.Second}");
    }

关于调试:

调试本程序如果没有服务端支持可用hfs这款软件,作为临时服务器进行调试使用方式非常简单下载好了之后界面如下


开发作者: JusterZhu & WELL-E

联系我们:
QQ群:

WELL-E

  • 1群 130108655
  • 2群 960655709
  • Git: https://github.com/WELL-E

juster.chu

  • E-Mail:zhuzhen723723@outlook.com
  • QQ: 580749909(个人群)
  • Blog: https://www.cnblogs.com/justzhuzhu/
  • Git: https://github.com/JusterZhu
  • 微信公众号

utlook.com

  • QQ: 580749909(个人群)
  • Blog: https://www.cnblogs.com/justzhuzhu/
  • Git: https://github.com/JusterZhu
  • 微信公众号

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/910229.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号