Skip to content
Merged

Dev #71

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
d7bee81
feature: 添加单元测试
JusterZhu Sep 3, 2024
e62dcff
refactor: 移除,除core库以外的所有驱动相关代码
JusterZhu Sep 6, 2024
e830f11
feature: add bowl.jpeg
JusterZhu Sep 7, 2024
c438a89
refactor: 重构管道机制
JusterZhu Sep 10, 2024
2b5d8cd
remove: 移除冗余代码
JusterZhu Sep 12, 2024
10d6099
refactor: refactor client core
JusterZhu Sep 20, 2024
aa6eb9b
refactor: refactor Generalupdate.zip
JusterZhu Sep 20, 2024
06c5ed8
refactor: Generalupdate.client
JusterZhu Sep 20, 2024
e400d9f
refactor: refactor generalupdate.upgrad
JusterZhu Sep 20, 2024
94e4729
refactor: refactor generalupdate.common
JusterZhu Sep 20, 2024
85c7a08
refactor: generalupdate.core
JusterZhu Sep 20, 2024
4bdd786
refactor: refactor generalupdate.differential
JusterZhu Sep 20, 2024
ea06802
refactor: generalupdate.upgrad
JusterZhu Sep 20, 2024
7c479c0
Update DriverMiddleware.cs
JusterZhu Sep 21, 2024
cbbd68f
Update GeneralUpdateBootstrap.cs
JusterZhu Sep 21, 2024
cb7ff3f
Update WindowsStrategy.cs
JusterZhu Sep 21, 2024
7dda81e
Update RestoreDriverCommand.cs
JusterZhu Sep 21, 2024
22fb2e1
Create FileExtensions.cs
JusterZhu Sep 22, 2024
0e03e47
拆分黑名单逻辑
JusterZhu Sep 23, 2024
c025d33
Update GeneralUpdateBootstrap.cs
JusterZhu Sep 24, 2024
75dd3e8
Update DifferentialCore.cs
JusterZhu Sep 24, 2024
086622b
Update FileExtensions.cs
JusterZhu Sep 24, 2024
ba8df21
Update GeneralUpdateOSS.cs
JusterZhu Oct 1, 2024
371aa96
Update GeneralUpdateBootstrap.cs
JusterZhu Oct 1, 2024
4e44f0b
Update GeneralClientBootstrap.cs
JusterZhu Oct 1, 2024
99972c3
Update GeneralUpdateOSS.cs
JusterZhu Oct 2, 2024
69a18a6
Update GeneralClientOSS.cs
JusterZhu Oct 3, 2024
2566e73
refactor: Reconstruct the entire structure
JusterZhu Nov 4, 2024
a6d0679
驱动更新实现
JusterZhu Nov 6, 2024
855ce67
调整命名空间
JusterZhu Nov 10, 2024
5e9018c
更新最新C# 语法
JusterZhu Nov 13, 2024
2b8a7d1
添加测试代码
JusterZhu Nov 13, 2024
a64f25c
完善bowl组件
JusterZhu Nov 14, 2024
7ef01df
Update WindowStrategy.cs
JusterZhu Nov 15, 2024
df6e2b9
更新OSS功能
JusterZhu Nov 15, 2024
92bdf9d
OSS AOT适配
JusterZhu Nov 15, 2024
438315e
移除encoding转换冗余代码
JusterZhu Nov 15, 2024
37b2070
适配AOT
JusterZhu Nov 15, 2024
f20cad3
完善推送升级订阅
JusterZhu Nov 16, 2024
b68b4c2
Update UpgradeHubService.cs
JusterZhu Nov 16, 2024
790875f
Update Program.cs
JusterZhu Nov 16, 2024
78bb7e2
适配Maui调整
JusterZhu Nov 16, 2024
fff595a
升级.NET9、升级有漏洞风险的nuget
JusterZhu Nov 17, 2024
61940d1
移除冗余代码
JusterZhu Nov 17, 2024
291da19
迁移maui自动升级部分
JusterZhu Nov 17, 2024
3e3b3a1
更新readme
JusterZhu Nov 17, 2024
4bfaf2e
Update dotnet-ci.yaml
JusterZhu Nov 17, 2024
4829443
Linux适配
JusterZhu Nov 18, 2024
dc43bd6
AOT适配
JusterZhu Nov 19, 2024
d7846bd
AOT适配
JusterZhu Nov 19, 2024
30f9114
移除压缩组件
JusterZhu Nov 25, 2024
9661b16
重构下载、消息通知
JusterZhu Nov 26, 2024
d3a6533
移除ZIP组件
JusterZhu Nov 26, 2024
d266c75
添加异常处理、修改命名错别字
JusterZhu Nov 27, 2024
c545d90
兼容signal r AOT
JusterZhu Nov 27, 2024
f56986d
修改readme
JusterZhu Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions .github/workflows/dotnet-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ jobs:
- name: Setup .NET SDK
uses: actions/setup-dotnet@v2
with:
dotnet-version: '8.0.x'
- name: Install .NET MAUI
run: dotnet workload install maui
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore ./src/c#/GeneralUpdate.sln
- name: build
Expand Down
141 changes: 49 additions & 92 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,133 +2,90 @@
![](https://img.shields.io/github/license/JusterZhu/GeneralUpdate?color=blue)


![](imgs/GeneralUpdate_h.png)
![](imgs/GeneralUpdate_h2.png)

[English introduction](https://github.com/JusterZhu/GeneralUpdate/blob/master/README_en.md)

## 1.组件介绍 ##

- GeneralUpdate是一款基于.NET Standard2.0开源自动升级组件。
- 运行环境:.NET7、.NET MAUI、Visual studio 2022(Preview)

![1708869360661](imgs/1708869360661.jpg)

| 功能 | 是否支持 | 备注 |
| ------------------------------ | -------- | ------------------------------------------------------------ |
| 断点续传 | 支持 | 单次更新失败时,下次一次启动时继续上一次更新下载更新包内容。(引用组件默认生效) |
| 逐版本更新 | 支持 | 客户端当前版本如果与服务器相差多个版本,则根据多个版本的发布日期逐个更新。(引用组件默认生效) |
| 二进制差分更新 | 支持 | 对比新老版本通过差分算法生成补丁文件。(引用组件默认生效) |
| 增量更新功能 | 支持 | 相比上一个版本只更新当前修改过的文件,并且删除当前版本不存在的文件。(引用组件默认生效) |
| 强制更新 | 支持 | 打开客户端之后直接强制更新。 |
| 多分支更新 | 支持 | 当一个产品有多个分支时,需要根据不同的分支更新对应的内容。 |
| 最新版本推送 | 支持 | 基于Signal R实现,推送当前最新版本。 |
| 客户端程序、服务端程序应用更新 | 支持 | C/S和B/S程序均可使用。 |
| 多平台、操作系统 | 部分支持 | Windows、MAUI Android平台 |
| 多语言 | 待验证 | 也可将本组件编写为控制台程序,作为更新“脚本”。更新其他语言的应用程序。 |
| 跳过更新 | 支持 | 支持注入弹窗让用户决定是否更新本次发布,服务端决定强制时更新不生效。 |
| 相互升级 | 支持 | 主程序可更新升级程序,升级程序可更新主程序。 |
| 黑名单 | 支持 | 在更新过程中会跳过黑名单中的文件列表和文件扩展名列表。 |
| OSS | 支持 | 极简化更新,是一套独立的更新机制。只需要在文件服务器中放置version.json的版本配置文件。组件会根据配置文件中的版本信息进行更新下载。(支持Windows,MAUI Android) |
| 回滚 | 待测试 | 逐版本更新时会备份每个版本,如果更新失败则逐版本回滚。 |
| 驱动更新 | 待测试 | 逐版本更新时会备份每个版本的驱动文件(.inf),如果更新失败则逐版本回滚。 |
| 遗言 | 待测试 | 开机时和升级时会检查升级是否成功,如果失败则根据遗言还原之前的备份。遗言是更新之前就已经自动创建在C:\generalupdate_willmessages目录下的will_message.json文件。will_message.json的内容是持久化回滚备份的文件目录相关信息。(需要部署GeneralUpdate.SystemService系统服务) |
| 自定义方法列表 | 支持 | 注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境) |



## 2.帮助文档 ##

- 讲解视频: https://www.bilibili.com/video/BV1aX4y137dd
- 官方网站: http://justerzhu.cn/
- 快速启动: https://mp.weixin.qq.com/s/pRKPFe3eC0NSqv9ixXEiTg
- 使用教程视频:https://www.bilibili.com/video/BV1FT4y1Y7hV
- 文档:https://gitee.com/GeneralLibrary/GeneralUpdate/tree/master/doc
GeneralUpdate是一款基于.NET Standard2.0开源自动升级组件。

帮助文档

## 3.开源地址 ##
- 官方网站: https://www.justerzhu.cn/
- 使用教程视频:https://www.bilibili.com/video/BV1FT4y1Y7hV

### 3.1当前项目GeneralUpdate
当前项目GeneralUpdate

- https://github.com/JusterZhu/GeneralUpdate
- https://gitee.com/Juster-zhu/GeneralUpdate

### 3.2打包工具项目地址GeneralUpdate.Tools
MAUI GeneralUpdate.Maui

- https://github.com/GeneralLibrary/GeneralUpdate.Maui

打包工具项目地址GeneralUpdate.Tools

- https://github.com/GeneralLibrary/GeneralUpdate.Tools
- https://gitee.com/GeneralTeam/GeneralUpdate.Tools

### 3.3示例项目地址GeneralUpdate-Samples
示例项目地址GeneralUpdate-Samples

- https://github.com/GeneralLibrary/GeneralUpdate-Samples

- https://gitee.com/GeneralTeam/GeneralUpdate-Samples

功能介绍:

| 功能 | 是否支持 | 备注 |
| -------------- | -------- | ------------------------------------------------------------ |
| 断点续传 | 支持 | 单次更新失败时,下次一次启动时继续上一次更新下载更新包内容。(引用组件默认生效) |
| 逐版本更新 | 支持 | 客户端当前版本如果与服务器相差多个版本,则根据多个版本的发布日期逐个更新。(引用组件默认生效) |
| 二进制差分更新 | 支持 | 对比新老版本通过差分算法生成补丁文件。(引用组件默认生效) |
| 增量更新功能 | 支持 | 相比上一个版本只更新当前修改过的文件,并且删除当前版本不存在的文件。(引用组件默认生效) |
| 强制更新 | 支持 | 打开客户端之后直接强制更新。 |
| 多分支更新 | 支持 | 当一个产品有多个分支时,需要根据不同的分支更新对应的内容。 |
| 最新版本推送 | 支持 | 基于Signal R实现,推送当前最新版本。 |
| 多语言 | 待验证 | 也可将本组件编写为控制台程序,作为更新“脚本”。更新其他语言的应用程序。 |
| 跳过更新 | 支持 | 支持注入弹窗让用户决定是否更新本次发布,服务端决定强制时更新不生效。 |
| 相互升级 | 支持 | 主程序可更新升级程序,升级程序可更新主程序。 |
| 黑名单 | 支持 | 在更新过程中会跳过黑名单中的文件列表和文件扩展名列表。 |
| OSS | 支持 | 极简化更新,是一套独立的更新机制。只需要在文件服务器中放置version.json的版本配置文件。组件会根据配置文件中的版本信息进行更新下载。 |
| 回滚、备份 | 支持 | 更新之前会将客户端本地文件备份,如果客户端启动失败或崩溃则回滚覆盖。 |
| 驱动更新 | 待验证 | 更新之前会将驱动备份到本地,如果客户端启动失败或崩溃则回滚覆盖。 |
| 自定义方法列表 | 支持 | 注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境) |
| AOT | 支持 | 支持AOT编译发布。 |


## 4.支持框架

| 框架名称 | 是否支持 |
## 2.支持框架

| .NET框架名称 | 是否支持 |
| -------------------------- | -------- |
| .NET Core 2.0 | 支持 |
| .NET 5 ... to last version | 支持 |
| .NET Framework 4.6.1 | 支持 |

| UI框架名称 | 是否支持 |
| ----------------- | --------------------- |
| WPF | 支持 |
| UWP | 商店模式下不可更新 |
| MAUI | 目前仅支持Android平台 |
| Avalonia | 支持 |
| WinUI | 待验证,等待反馈 |
| Console(控制台) | 支持 |
| Winform | 支持 |

| 服务端框架 | 是否支持 |
| ---------- | -------- |
| ASP.NET | 待验证 |
| UI框架名称 | 是否支持 |
| ---------- | --------------------- |
| WPF | 支持 |
| UWP | 商店模式下不可更新 |
| MAUI | 目前仅支持Android平台 |
| Avalonia | 支持 |
| WinUI | 支持 |
| Console | 支持 |
| WinForms | 支持 |



## 5.操作系统
## 3.操作系统

| 操作系统名称 | 是否支持 |
| ------------ | -------- |
| Windows | 支持 |
| Linux | 待验证 |
| Mac | 待验证 |
| Linux | 支持 |
| Android | 支持 |
| 树莓派(IoT) | 待验证 |
| 麒麟V10(飞腾S2500) | 支持 |
| 麒麟V10(x64) | 支持 |



## 6.GeneralUpdate.SystemService发布/部署

GeneralUpdate.SystemService是一个windows系统服务,并不是部署在服务端的web api。它的主要作用是监听更新过程,以及更新崩溃之后还原。

**发布:**

推荐发布Single file,如果想发布AOT版本需要移除源码中映射代码。

```shell
dotnet publish -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
```

**创建/部署windows服务:**

```shell
sc create MyWorkerService binPath="C:\your_path\GeneralUpdate.SystemService.exe"
```

**启动已部署的windows服务:**

```shell
sc start GeneralUpdate.SystemService
```

**删除已部署的windows服务:**

```shell
sc delete GeneralUpdate.SystemService
```

| Ubuntu | 支持 |
| 龙芯(Loongnix) | 待验证 |
33 changes: 0 additions & 33 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,36 +92,3 @@
| raspberry pie | Not currently supported |
| Kylin V10 (FT-S2500) | yes |
| Kylin V10 (x64) | yes |



## GeneralUpdate.SystemService Publish/Deploy

GeneralUpdate.SystemService is a Windows system service, not a web API deployed on the server. Its main purpose is to listen for the update process and restore after an update crash.

**Publish:**

It is recommended to release a single file, if you want to release the AOT version, you need to remove the mapping code from the source code.

```shell
dotnet publish -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
```

**Create/deploy Windows services:**

```shell
sc create MyWorkerService binPath="C:\your_path\GeneralUpdate.SystemService.exe"
```

**Start the deployed Windows service:**

```shell
sc start GeneralUpdate.SystemService
```

**Delete the deployed Windows service:**

```shell
sc delete GeneralUpdate.SystemService
```

Binary file removed imgs/1708869360661.jpg
Binary file not shown.
Binary file added imgs/GeneralUpdate_h2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added imgs/bowl.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions src/c#/GeneralUpdate.Bowl/Applications/Windows/export.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@echo off
setlocal

if "%~1"=="" (
echo Please provide the export path as the first parameter.
exit /b 1
)

set exportDir=%~1

if not exist "%exportDir%" (
mkdir "%exportDir%"
)

set outputFile=%exportDir%\driverInfo.txt

:: 导出驱动信息
driverquery /v /fo table > "%outputFile%"
echo %outputFile% Export successfully.

:: 导出系统信息
set systemInfoFile=%exportDir%\systeminfo.txt
systeminfo > "%systemInfoFile%"
echo %systemInfoFile% Export successfully.

:: 获取当前日期
for /f "tokens=1-4 delims=/- " %%i in ('date /t') do (
set yyyy=%%i
set mm=%%j
set dd=%%k
)

:: 设置日志文件名
set logFile=%exportDir%\systemlog.evtx

:: 导出系统日志
wevtutil epl System "%logFile%" /q:"*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]"
echo %logFile% Export successfully.

endlocal
61 changes: 40 additions & 21 deletions src/c#/GeneralUpdate.Bowl/Bowl.cs
Original file line number Diff line number Diff line change
@@ -1,39 +1,58 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text.Json;
using GeneralUpdate.Bowl.Strategys;
using GeneralUpdate.Common.Internal.JsonContext;
using GeneralUpdate.Common.Shared.Object;

namespace GeneralUpdate.Bowl;

public class Bowl
/// <summary>
/// Surveillance Main Program.
/// </summary>
public sealed class Bowl
{
private IStrategy _strategy;
private static IStrategy? _strategy;

public Bowl(MonitorParameter parameter = null)
{
CreateStrategy();
_strategy!.SetParameter(parameter);
}
private Bowl() { }

private void CreateStrategy()
private static void CreateStrategy()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
_strategy = new WindowStrategy();
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
_strategy = new LinuxStrategy();
}

if (_strategy == null)
throw new PlatformNotSupportedException("Unsupported operating system");
}

public static void Launch(MonitorParameter? monitorParameter = null)
{
monitorParameter ??= CreateParameter();
CreateStrategy();
_strategy?.SetParameter(monitorParameter);
_strategy?.Launch();
}

public Bowl SetParameter(MonitorParameter parameter)
private static MonitorParameter CreateParameter()
{
if(parameter.Verify())
throw new ArgumentException("Parameter contains illegal values");
var json = Environment.GetEnvironmentVariable("ProcessInfo", EnvironmentVariableTarget.User);
if(string.IsNullOrWhiteSpace(json))
throw new ArgumentNullException("ProcessInfo environment variable not set !");

_strategy.SetParameter(parameter);
return this;
var processInfo = JsonSerializer.Deserialize<ProcessInfo>(json, ProcessInfoJsonContext.Default.ProcessInfo);
if(processInfo == null)
throw new ArgumentNullException("ProcessInfo json deserialize fail!");

return new MonitorParameter
{
ProcessNameOrId = processInfo.AppName,
DumpFileName = $"{processInfo.LastVersion}_fail.dmp",
FailFileName = $"{processInfo.LastVersion}_fail.json",
TargetPath = processInfo.InstallPath,
FailDirectory = Path.Combine(processInfo.InstallPath, "fail", processInfo.LastVersion),
BackupDirectory = Path.Combine(processInfo.InstallPath, processInfo.LastVersion),
ExtendedField = processInfo.LastVersion
};
}

public void Launch() => _strategy.Launch();
}
11 changes: 11 additions & 0 deletions src/c#/GeneralUpdate.Bowl/GeneralUpdate.Bowl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@
<None Update="Applications\Linux\procdump_3.3.0_amd64.deb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Applications\Windows\export.bat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\GeneralUpdate.Common\GeneralUpdate.Common.csproj" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions src/c#/GeneralUpdate.Bowl/Internal/Crash.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;
using GeneralUpdate.Bowl.Strategys;

namespace GeneralUpdate.Bowl.Internal;

internal class Crash
{
public MonitorParameter Parameter { get; set; }

public List<string> ProcdumpOutPutLines { get; set; }
}
6 changes: 6 additions & 0 deletions src/c#/GeneralUpdate.Bowl/Internal/CrashJsonContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using System.Text.Json.Serialization;

namespace GeneralUpdate.Bowl.Internal;

[JsonSerializable(typeof(Crash))]
internal partial class CrashJsonContext : JsonSerializerContext;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GeneralUpdate.Bowl.Strategys;
namespace GeneralUpdate.Bowl.Internal;

internal class LinuxSystem
{
Expand Down
Loading