GeneralUpdate 2021.08.14更新公告

GeneralUpdate是基于.net standard2.0开发的一款(c/s应用)自动升级程序。该组件将更新的核心部分抽离出来方便应用于多种项目当中目前适用于wpf,控制台应用,winfrom。

1.Notice

  • 预计会使用Blazor开发GeneralUpdate官网,介绍组件结构、更新流程、快速启动、参数等内容。


1.主程序启动时检测升级程序是否需要更新

2.需要更新则把升级程序版本号上传并逐版本更新

3.升级程序更完成后或不需要更新,则进行判断主程序 是否需要更新如果需要更新则启动升级程序

4.请求主程序更新版本

5.请求到主版本多个更新包并逐版本更新 6.更新完成后关闭升级程序启动主程序

  • 以上更新、下载过程均支持断点续传和逐版本更新。
  • 逐版本下载功能是根据版本发布时间进行排序的发布时间越早的版本越先更新(具体信息见源码中的sql脚本字段内容)。
  • 逐版本下载的更新包最大测试过1G更新内容。

2.Nuget

3.Issues & Git 、Gitee

欢迎在以下地址提出issues提出时尽可能的描述清楚异常发生的原因或缺陷详情,check周期为每周的周五。

4.New

  • GeneralUpdate.Core添加逐版本更新功能
  • GeneralUpdate.Core新增事件ExceptionEvent、MutiDownloadStatisticsEvent、MutiDownloadErrorEvent、MutiDownloadCompletedEvent、MutiDownloadProgressEvent、MutiAllDownloadCompletedEvent。
  • GeneralUpdate.Core新增RemoteAddressBase64方法。
  • 新增ClientParameter类,用于组件之间进程通讯传递参数。
  • 新增组件GeneralUpdate.AspNetCore,具有根据升级类型返回更新版本信息的功能并支持管道依赖注入使用,但需要自己编写查库的方法。
  • 新增组件GeneralUpdate.ClientCore,
    • (1)具有更新升级组件版本功能(更新程序更新自己)
    • (2)支持升级组件的逐版本更新(多更新包同时下载)
    • (3)便捷启动升级程序,摆脱之前的繁琐进程启动和传参。

 

  • 新增组件GeneralUpdate.Common 该库整合了组件内使用的所有公共类和辅助方法(该组件为必须组件,该组件更新频率非常低不推荐打包在更新包中)。
  • 新增mysql脚本,用于创建GeneralUpdate.AspNetCore服务端使用的update_version表。

5.Remove

  • 移除GeneralUpdate.Core中所有的通知事件替换为MutixxxxEvent.
  • 移除GeneralUpdate.Core中GeneralUpdateBootstrap启动中通过进程传递参数的方法RemoteAddress方法。
  • 移除更新失败版本回滚功能,该功能导致在C盘回滚更新时因权限不够发生致命异常问题,该功能考虑后续开放。

6.Fix

  • 修复https ssl访问失败问题。
  • 修复其他.net框架版本注册事件begininvoke通知异常问题。
  • 修改多处类名单词拼写错误问题。
  • 对若干Model类删除了不必要字段。

7.Quick Start

(1) Example GeneralUpdate.ClientCore

//Clinet version.
            var mainVersion = "1.1.1";
            var mianType = 1;

            //Updater version
            clientParameter = new ClientParameter();
            clientParameter.ClientVersion = "1.1.1";
            clientParameter.ClientType = 2;
            clientParameter.AppName = "AutoUpdate.ConsoleApp";
            clientParameter.MainAppName = "AutoUpdate.Test";
            clientParameter.InstallPath = @"D:\update_test";
            clientParameter.UpdateLogUrl = "https://www.baidu.com/";
            clientParameter.ValidateUrl = $"https://127.0.0.1:5001/api/update/getUpdateValidate/{ clientParameter.ClientType }/{ clientParameter.ClientVersion }";
            clientParameter.UpdateUrl = $"https://127.0.0.1:5001/api/update/getUpdateVersions/{ clientParameter.ClientType }/{ clientParameter.ClientVersion }";
            clientParameter.MainValidateUrl = $"https://127.0.0.1:5001/api/update/getUpdateValidate/{ mianType }/{ mainVersion }";
            clientParameter.MainUpdateUrl = $"https://127.0.0.1:5001/api/update/getUpdateVersions/{ mianType }/{ mainVersion }";

            generalClientBootstrap = new GeneralClientBootstrap();
            generalClientBootstrap.MutiDownloadProgressChanged += OnMutiDownloadProgressChanged;
            generalClientBootstrap.MutiDownloadStatistics += OnMutiDownloadStatistics;
            generalClientBootstrap.MutiDownloadCompleted += OnMutiDownloadCompleted;
            generalClientBootstrap.MutiAllDownloadCompleted += OnMutiAllDownloadCompleted;
            generalClientBootstrap.MutiDownloadError += OnMutiDownloadError;
            generalClientBootstrap.Exception += OnException;
            generalClientBootstrap.Config(clientParameter).
                Strategy<ClientStrategy>();
            await generalClientBootstrap.LaunchTaskAsync();

(2) Example GeneralUpdate.Core

static void Main(string[] args)
    {
        var resultBase64 = args[0];
        var bootstrap = new GeneralUpdateBootstrap();
        bootstrap.Exception += OnException;
        bootstrap.MutiDownloadError += OnMutiDownloadError;
        bootstrap.MutiDownloadCompleted += OnMutiDownloadCompleted;
        bootstrap.MutiDownloadStatistics += OnMutiDownloadStatistics;
        bootstrap.MutiDownloadProgressChanged += OnMutiDownloadProgressChanged;
        bootstrap.MutiAllDownloadCompleted += OnMutiAllDownloadCompleted;
        bootstrap.Strategy<DefaultStrategy>().
            Option(UpdateOption.DownloadTimeOut, 60).
            RemoteAddressBase64(resultBase64).
            LaunchAsync();
    }

(3) Example GeneralUpdate.AspNetCore

Startup.cs
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();
        services.AddSingleton<IUpdateService, GeneralUpdateService>();
    }

    UpdateController.cs

    private readonly ILogger<UpdateController> _logger;
    private readonly IUpdateService _updateService;

    public UpdateController(ILogger<UpdateController> logger, IUpdateService updateService)
    {
        _logger = logger;
        _updateService = updateService;
    }

    /// <summary>
    /// https://localhost:5001/api/update/getUpdateVersions/1/1.1.1
    /// </summary>
    /// <param name="clientType"> 1:ClientApp 2:UpdateApp</param>
    /// <param name="clientVersion"></param>
    /// <returns></returns>
    [HttpGet("getUpdateVersions/{clientType}/{clientVersion}")]
    public async Task<IActionResult> GetUpdateVersions(int clientType, string clientVersion)
    {
        _logger.LogInformation("Client request 'GetUpdateVersions'.");
        var resultJson = await _updateService.UpdateVersionsTaskAsync(clientType, clientVersion, UpdateVersions);
        return Ok(resultJson);
    }

    /// <summary>
    /// https://localhost:5001/api/update/getUpdateValidate/1/1.1.1
    /// </summary>
    /// <param name="clientType"> 1:ClientApp 2:UpdateApp</param>
    /// <param name="clientVersion"></param>
    /// <returns></returns>
    [HttpGet("getUpdateValidate/{clientType}/{clientVersion}")]
    public async Task<IActionResult> GetUpdateValidate(int clientType, string clientVersion)
    {
        _logger.LogInformation("Client request 'GetUpdateValidate'.");
        var lastVersion = GetLastVersion();
        var resultJson = await _updateService.UpdateValidateTaskAsync(clientType, clientVersion, lastVersion, true, GetValidateInfos);
        return Ok(resultJson);
    }
posted @ 2021-08-15 00:52  justerzhu  阅读(214)  评论(0编辑  收藏  举报