GeneralUpdate2.1.0发布

Stella981
• 阅读 565

GeneralUpdate

  • GeneralUpdate是基于.net framwork开发的一款(c/s应用)自动升级程序。该组件将更新的核心部分抽离出来方便应用于多种项目当中目前适用于wpf,控制台应用,winfrom。相比以前更方便的是不需要在过分关注源码可直接通过nuget直接使用。
  • 如果有任何使用问题可以在Github的issues上进行提问我会每周统一找时间解决并解答bug或者问题。或者联系文章末尾的联系方式会有人解答。
  • 每次迭代新版本doc文件夹中的帮助文档也会随之更新,各位开发者请多关注。
  • 如果该组件能够帮助到您,希望可以点个Strat和关注一下文档末尾的联系方式。您的支持是对开源作者最大的支持与帮助。

How to use it:

Gitee(码云)地址:

Nuget地址:

GeneralUpdate2.1.0发布

GeneralUpdate2.1.0发布

GitHub地址:


GeneralUpdate2.1.0发布

1.版本更新2020-8-30

  1. 在新的发布中,GeneralUpdate.Core-2.1.0版本新增断点续传功能。

  2. 在新的发布中,新增了组件 GeneralUpdate.Single-1.0.0,它将为程序带来单例运行功能,防止自动更新程序开启多个。

2.更新流程

1.客户端程序启动,向服务器获取更新信息解析并比对是否需要更新。

2.解析进程传参。例如:本机版本号、最新版本号、下载地址、解压路径、安装路径等。

3.客户端程序启动更新程序(GeneralUpdate),关闭自身(客户端把自己关掉)。

4.自动更新程序(GeneralUpdate)根据传递的更新信息进行, (1)下载、(2)MD5校验、(3)解压、(4)删除更新文件、(5)替换更新文件、(6)关闭更新程序自身、(7)启动客户端。

5.完成更新

3.进程之间相互调用

此段代码来自于msdn

using System;
using System.Diagnostics;
using System.ComponentModel;

namespace MyProcessSample
{
    class MyProcess
    {
        // Opens the Internet Explorer application.
        void OpenApplication(string myFavoritesPath)
        {
            // Start Internet Explorer. Defaults to the home page.
            Process.Start("IExplore.exe");

            // Display the contents of the favorites folder in the browser.
            Process.Start(myFavoritesPath);
        }

        // Opens urls and .html documents using Internet Explorer.
        void OpenWithArguments()
        {
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");

            // Start a Web page using a browser associated with .html and .asp files.
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
            Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
        }

        // Uses the ProcessStartInfo class to start new processes,
        // both in a minimized mode.
        void OpenWithStartInfo()
        {
            ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
            startInfo.WindowStyle = ProcessWindowStyle.Minimized;

            Process.Start(startInfo);

            startInfo.Arguments = "www.northwindtraders.com";

            Process.Start(startInfo);
        }

        static void Main()
        {
            // Get the path that stores favorite links.
            string myFavoritesPath =
                Environment.GetFolderPath(Environment.SpecialFolder.Favorites);

            MyProcess myProcess = new MyProcess();

            myProcess.OpenApplication(myFavoritesPath);
            myProcess.OpenWithArguments();
            myProcess.OpenWithStartInfo();
        }
    }
}

3.GeneralUpdate.Core-2.1.0使用方式

#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<DefultStrategy>().//注册策略,可自定义更新流程
            Option(UpdateOption.Format, "zip").//指定更新包的格式,目前只支持zip
            Option(UpdateOption.MainApp, "your application name").//指定更新完成后需要启动的主程序名称不需要加.exe直接写名称即可
            Option(UpdateOption.DownloadTimeOut,60).//下载超时时间(单位:秒),如果不指定则默认超时时间为30秒。
            RemoteAddress(args).//这里的参数保留了之前的参数数组集合
            Launch();//启动更新

        #endregion

        #region Launch2

        /*
         * Launch2
         * 新增了第二种启动方式
         * 流程:
         * 1.指定更新地址,https://api.com/GeneralUpdate?version=1.0.0.1 在webapi中传入客户端当前版本号
         * 2.如果需要更新api回返回给你所有的更新信息(详情内容参考 /Models/UpdateInfo.cs)
         * 3.拿到更新信息之后则开始http请求更新包
         * 4.下载
         * 5.解压
         * 6.更新本地文件
         * 7.关闭更新程序
         * 8.启动配置好主程序
         * 更新程序必须跟主程序放在同级目录下
         */

        //GeneralUpdateBootstrap bootstrap2 = new GeneralUpdateBootstrap();
        //bootstrap2.DownloadStatistics += OnDownloadStatistics;
        //bootstrap2.ProgressChanged += OnProgressChanged;
        //bootstrap2.Strategy<DefultStrategy>().
        //    Option(UpdateOption.Format, "zip").
        //    Option(UpdateOption.MainApp, "").
        //      Option(UpdateOption.DownloadTimeOut,60).//下载超时时间(单位:秒),如果不指定则默认超时时间为30秒。
        //    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}");
    }

3.GeneralUpdate.Single-1.0.0使用方式

/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application, ISingleInstanceApp
{
    private const string AppId = "{7F280539-0814-4F9C-95BF-D2BB60023657}";

    [STAThread]
    protected override void OnStartup(StartupEventArgs e)
    {
        string[] resultArgs = null;

        if (e.Args == null || e.Args.Length == 0)
        {
            resultArgs = 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",
             };
        }
        else
        {
            resultArgs = e.Args;
        }

        if (resultArgs.Length != 6) return;
        if (SingleInstance<App>.InitializeAsFirstInstance(AppId))
        {
            var win = new MainWindow();
            var vm = new MainViewModel(resultArgs, win.Close);
            win.DataContext = vm;

            var application = new App();
            application.InitializeComponent();
            application.Run(win);
            SingleInstance<App>.Cleanup();
        }
    }

    public bool SignalExternalCommandLineArgs(IList<string> args)
    {
        if (this.MainWindow.WindowState == WindowState.Minimized)
        {
            this.MainWindow.WindowState = WindowState.Normal;
        }
        this.MainWindow.Activate();

        return true;
    }
}

4.问答Q&A


Q1.如果版本迭代多次,跨版本更新,该怎么办呢?

A1:只要不是框架级别的更新都是可以更新的。 不管你迭代多少次跨了多少个版本,你把最终的包放到服务器上就行了。这个里面没有涉及到增量更新,所以你更新多了直接把所有的新文件覆盖上去就行了。

Q2.GeneralUpdate是跟客户端是一个整体吗?

A2: 不是,GeneralUpdate是一个独立于客户端的程序。

Q3:能不能增量更新、失败自动回滚、更新本地数据或配置文件?

A3: 目前不能。(该功能已在开发计划当中)。

Q4:GeneralUpdate是如何更新的?

A4: 更新的方式为把本地原有的客户端文件进行覆盖。

点赞
收藏
评论区
推荐文章
blmius blmius
2年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
待兔 待兔
2星期前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Stella981 Stella981
2年前
Service starting has been prevented by iaware or trustsbase sInfo ServiceInfo 解决方法
问题:ActivityManager:ServicestartinghasbeenpreventedbyiawareortrustsbasesInfoServiceInfo{c50ea35xxx.xxx.xxx.ServiceName}问题描述,该问题再华为部分手机升级到Android10.1之后,启动服务会
Stella981 Stella981
2年前
Android So动态加载 优雅实现与原理分析
背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我
Wesley13 Wesley13
2年前
35岁,真的是程序员的一道坎吗?
“程序员35岁是道坎”,“程序员35岁被裁”……这些话咱们可能都听腻了,但每当触及还是会感到丝丝焦虑,毕竟每个人都会到35岁。而国内互联网环境确实对35岁以上的程序员不太友好:薪资要得高,却不如年轻人加班猛;虽说经验丰富,但大部分公司并不需要太资深的程序员。但35岁危机并不是不可避免的,比如你可以不断精进技术,将来做技术管理或者
Wesley13 Wesley13
2年前
.Net WPF自动更新程序GeneralUpdate
GeneralUpdateGeneralUpdate是基于.netframwork4.5.2开发的一款(c/s应用)自动升级程序。第一个版本叫Autoupdate(原博客:WPF自动更新程序(https://www.oschina.net/action/GoToLink?urlhttps%3A%2F%2Fwww.
Wesley13 Wesley13
2年前
35岁是技术人的天花板吗?
35岁是技术人的天花板吗?我非常不认同“35岁现象”,人类没有那么脆弱,人类的智力不会说是35岁之后就停止发展,更不是说35岁之后就没有机会了。马云35岁还在教书,任正非35岁还在工厂上班。为什么技术人员到35岁就应该退役了呢?所以35岁根本就不是一个问题,我今年已经37岁了,我发现我才刚刚找到自己的节奏,刚刚上路。
Python进阶者 Python进阶者
6个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这