Skip to content

Commit a37a9a7

Browse files
JusterZhugitee-org
authored andcommitted
!57 Dev
Merge pull request !57 from Juster Zhu/dev
2 parents a42bdc8 + f56986d commit a37a9a7

File tree

309 files changed

+4589
-11542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

309 files changed

+4589
-11542
lines changed

.github/workflows/dotnet-ci.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ jobs:
1111
- name: Setup .NET SDK
1212
uses: actions/setup-dotnet@v2
1313
with:
14-
dotnet-version: '8.0.x'
15-
- name: Install .NET MAUI
16-
run: dotnet workload install maui
14+
dotnet-version: '9.0.x'
1715
- name: Restore dependencies
1816
run: dotnet restore ./src/c#/GeneralUpdate.sln
1917
- name: build

README.md

Lines changed: 49 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -2,133 +2,90 @@
22
![](https://img.shields.io/github/license/JusterZhu/GeneralUpdate?color=blue)
33

44

5-
![](imgs/GeneralUpdate_h.png)
5+
![](imgs/GeneralUpdate_h2.png)
66

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

99
## 1.组件介绍 ##
1010

11-
- GeneralUpdate是一款基于.NET Standard2.0开源自动升级组件。
12-
- 运行环境:.NET7、.NET MAUI、Visual studio 2022(Preview)
13-
14-
![1708869360661](imgs/1708869360661.jpg)
15-
16-
| 功能 | 是否支持 | 备注 |
17-
| ------------------------------ | -------- | ------------------------------------------------------------ |
18-
| 断点续传 | 支持 | 单次更新失败时,下次一次启动时继续上一次更新下载更新包内容。(引用组件默认生效) |
19-
| 逐版本更新 | 支持 | 客户端当前版本如果与服务器相差多个版本,则根据多个版本的发布日期逐个更新。(引用组件默认生效) |
20-
| 二进制差分更新 | 支持 | 对比新老版本通过差分算法生成补丁文件。(引用组件默认生效) |
21-
| 增量更新功能 | 支持 | 相比上一个版本只更新当前修改过的文件,并且删除当前版本不存在的文件。(引用组件默认生效) |
22-
| 强制更新 | 支持 | 打开客户端之后直接强制更新。 |
23-
| 多分支更新 | 支持 | 当一个产品有多个分支时,需要根据不同的分支更新对应的内容。 |
24-
| 最新版本推送 | 支持 | 基于Signal R实现,推送当前最新版本。 |
25-
| 客户端程序、服务端程序应用更新 | 支持 | C/S和B/S程序均可使用。 |
26-
| 多平台、操作系统 | 部分支持 | Windows、MAUI Android平台 |
27-
| 多语言 | 待验证 | 也可将本组件编写为控制台程序,作为更新“脚本”。更新其他语言的应用程序。 |
28-
| 跳过更新 | 支持 | 支持注入弹窗让用户决定是否更新本次发布,服务端决定强制时更新不生效。 |
29-
| 相互升级 | 支持 | 主程序可更新升级程序,升级程序可更新主程序。 |
30-
| 黑名单 | 支持 | 在更新过程中会跳过黑名单中的文件列表和文件扩展名列表。 |
31-
| OSS | 支持 | 极简化更新,是一套独立的更新机制。只需要在文件服务器中放置version.json的版本配置文件。组件会根据配置文件中的版本信息进行更新下载。(支持Windows,MAUI Android) |
32-
| 回滚 | 待测试 | 逐版本更新时会备份每个版本,如果更新失败则逐版本回滚。 |
33-
| 驱动更新 | 待测试 | 逐版本更新时会备份每个版本的驱动文件(.inf),如果更新失败则逐版本回滚。 |
34-
| 遗言 | 待测试 | 开机时和升级时会检查升级是否成功,如果失败则根据遗言还原之前的备份。遗言是更新之前就已经自动创建在C:\generalupdate_willmessages目录下的will_message.json文件。will_message.json的内容是持久化回滚备份的文件目录相关信息。(需要部署GeneralUpdate.SystemService系统服务) |
35-
| 自定义方法列表 | 支持 | 注入一个自定义方法集合,该集合会在更新启动前执行。执行自定义方法列表如果出现任何异常,将通过异常订阅通知。(推荐在更新之前检查当前软件环境) |
36-
37-
38-
39-
## 2.帮助文档 ##
40-
41-
- 讲解视频: https://www.bilibili.com/video/BV1aX4y137dd
42-
- 官方网站: http://justerzhu.cn/
43-
- 快速启动: https://mp.weixin.qq.com/s/pRKPFe3eC0NSqv9ixXEiTg
44-
- 使用教程视频:https://www.bilibili.com/video/BV1FT4y1Y7hV
45-
- 文档:https://gitee.com/GeneralLibrary/GeneralUpdate/tree/master/doc
11+
GeneralUpdate是一款基于.NET Standard2.0开源自动升级组件。
12+
13+
帮助文档
4614

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

49-
### 3.1当前项目GeneralUpdate
18+
当前项目GeneralUpdate
5019

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

54-
### 3.2打包工具项目地址GeneralUpdate.Tools
23+
MAUI GeneralUpdate.Maui
24+
25+
- https://github.com/GeneralLibrary/GeneralUpdate.Maui
26+
27+
打包工具项目地址GeneralUpdate.Tools
5528

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

59-
### 3.3示例项目地址GeneralUpdate-Samples
32+
示例项目地址GeneralUpdate-Samples
6033

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

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

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

6659

67-
## 4.支持框架
6860

69-
| 框架名称 | 是否支持 |
61+
## 2.支持框架
62+
63+
| .NET框架名称 | 是否支持 |
7064
| -------------------------- | -------- |
7165
| .NET Core 2.0 | 支持 |
7266
| .NET 5 ... to last version | 支持 |
7367
| .NET Framework 4.6.1 | 支持 |
7468

75-
| UI框架名称 | 是否支持 |
76-
| ----------------- | --------------------- |
77-
| WPF | 支持 |
78-
| UWP | 商店模式下不可更新 |
79-
| MAUI | 目前仅支持Android平台 |
80-
| Avalonia | 支持 |
81-
| WinUI | 待验证,等待反馈 |
82-
| Console(控制台) | 支持 |
83-
| Winform | 支持 |
84-
85-
| 服务端框架 | 是否支持 |
86-
| ---------- | -------- |
87-
| ASP.NET | 待验证 |
69+
| UI框架名称 | 是否支持 |
70+
| ---------- | --------------------- |
71+
| WPF | 支持 |
72+
| UWP | 商店模式下不可更新 |
73+
| MAUI | 目前仅支持Android平台 |
74+
| Avalonia | 支持 |
75+
| WinUI | 支持 |
76+
| Console | 支持 |
77+
| WinForms | 支持 |
8878

8979

9080

91-
## 5.操作系统
81+
## 3.操作系统
9282

9383
| 操作系统名称 | 是否支持 |
9484
| ------------ | -------- |
9585
| Windows | 支持 |
96-
| Linux | 待验证 |
97-
| Mac | 待验证 |
86+
| Linux | 支持 |
9887
| Android | 支持 |
99-
| 树莓派(IoT) | 待验证 |
10088
| 麒麟V10(飞腾S2500) | 支持 |
10189
| 麒麟V10(x64) | 支持 |
102-
103-
104-
105-
## 6.GeneralUpdate.SystemService发布/部署
106-
107-
GeneralUpdate.SystemService是一个windows系统服务,并不是部署在服务端的web api。它的主要作用是监听更新过程,以及更新崩溃之后还原。
108-
109-
**发布:**
110-
111-
推荐发布Single file,如果想发布AOT版本需要移除源码中映射代码。
112-
113-
```shell
114-
dotnet publish -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
115-
```
116-
117-
**创建/部署windows服务:**
118-
119-
```shell
120-
sc create MyWorkerService binPath="C:\your_path\GeneralUpdate.SystemService.exe"
121-
```
122-
123-
**启动已部署的windows服务:**
124-
125-
```shell
126-
sc start GeneralUpdate.SystemService
127-
```
128-
129-
**删除已部署的windows服务:**
130-
131-
```shell
132-
sc delete GeneralUpdate.SystemService
133-
```
134-
90+
| Ubuntu | 支持 |
91+
| 龙芯(Loongnix) | 待验证 |

README_en.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -92,36 +92,3 @@
9292
| raspberry pie | Not currently supported |
9393
| Kylin V10 (FT-S2500) | yes |
9494
| Kylin V10 (x64) | yes |
95-
96-
97-
98-
## GeneralUpdate.SystemService Publish/Deploy
99-
100-
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.
101-
102-
**Publish:**
103-
104-
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.
105-
106-
```shell
107-
dotnet publish -r win-x64 -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true --self-contained true
108-
```
109-
110-
**Create/deploy Windows services:**
111-
112-
```shell
113-
sc create MyWorkerService binPath="C:\your_path\GeneralUpdate.SystemService.exe"
114-
```
115-
116-
**Start the deployed Windows service:**
117-
118-
```shell
119-
sc start GeneralUpdate.SystemService
120-
```
121-
122-
**Delete the deployed Windows service:**
123-
124-
```shell
125-
sc delete GeneralUpdate.SystemService
126-
```
127-

imgs/1708869360661.jpg

-165 KB
Binary file not shown.

imgs/GeneralUpdate_h2.png

32.9 KB
Loading

imgs/bowl.jpeg

100 KB
Loading
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
@echo off
2+
setlocal
3+
4+
if "%~1"=="" (
5+
echo Please provide the export path as the first parameter.
6+
exit /b 1
7+
)
8+
9+
set exportDir=%~1
10+
11+
if not exist "%exportDir%" (
12+
mkdir "%exportDir%"
13+
)
14+
15+
set outputFile=%exportDir%\driverInfo.txt
16+
17+
:: 导出驱动信息
18+
driverquery /v /fo table > "%outputFile%"
19+
echo %outputFile% Export successfully.
20+
21+
:: 导出系统信息
22+
set systemInfoFile=%exportDir%\systeminfo.txt
23+
systeminfo > "%systemInfoFile%"
24+
echo %systemInfoFile% Export successfully.
25+
26+
:: 获取当前日期
27+
for /f "tokens=1-4 delims=/- " %%i in ('date /t') do (
28+
set yyyy=%%i
29+
set mm=%%j
30+
set dd=%%k
31+
)
32+
33+
:: 设置日志文件名
34+
set logFile=%exportDir%\systemlog.evtx
35+
36+
:: 导出系统日志
37+
wevtutil epl System "%logFile%" /q:"*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]"
38+
echo %logFile% Export successfully.
39+
40+
endlocal

src/c#/GeneralUpdate.Bowl/Bowl.cs

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,58 @@
11
using System;
2+
using System.IO;
23
using System.Runtime.InteropServices;
4+
using System.Text.Json;
35
using GeneralUpdate.Bowl.Strategys;
6+
using GeneralUpdate.Common.Internal.JsonContext;
7+
using GeneralUpdate.Common.Shared.Object;
48

59
namespace GeneralUpdate.Bowl;
610

7-
public class Bowl
11+
/// <summary>
12+
/// Surveillance Main Program.
13+
/// </summary>
14+
public sealed class Bowl
815
{
9-
private IStrategy _strategy;
16+
private static IStrategy? _strategy;
1017

11-
public Bowl(MonitorParameter parameter = null)
12-
{
13-
CreateStrategy();
14-
_strategy!.SetParameter(parameter);
15-
}
18+
private Bowl() { }
1619

17-
private void CreateStrategy()
20+
private static void CreateStrategy()
1821
{
1922
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
20-
{
2123
_strategy = new WindowStrategy();
22-
}
23-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
24-
{
25-
_strategy = new LinuxStrategy();
26-
}
24+
25+
if (_strategy == null)
26+
throw new PlatformNotSupportedException("Unsupported operating system");
27+
}
28+
29+
public static void Launch(MonitorParameter? monitorParameter = null)
30+
{
31+
monitorParameter ??= CreateParameter();
32+
CreateStrategy();
33+
_strategy?.SetParameter(monitorParameter);
34+
_strategy?.Launch();
2735
}
2836

29-
public Bowl SetParameter(MonitorParameter parameter)
37+
private static MonitorParameter CreateParameter()
3038
{
31-
if(parameter.Verify())
32-
throw new ArgumentException("Parameter contains illegal values");
39+
var json = Environment.GetEnvironmentVariable("ProcessInfo", EnvironmentVariableTarget.User);
40+
if(string.IsNullOrWhiteSpace(json))
41+
throw new ArgumentNullException("ProcessInfo environment variable not set !");
3342

34-
_strategy.SetParameter(parameter);
35-
return this;
43+
var processInfo = JsonSerializer.Deserialize<ProcessInfo>(json, ProcessInfoJsonContext.Default.ProcessInfo);
44+
if(processInfo == null)
45+
throw new ArgumentNullException("ProcessInfo json deserialize fail!");
46+
47+
return new MonitorParameter
48+
{
49+
ProcessNameOrId = processInfo.AppName,
50+
DumpFileName = $"{processInfo.LastVersion}_fail.dmp",
51+
FailFileName = $"{processInfo.LastVersion}_fail.json",
52+
TargetPath = processInfo.InstallPath,
53+
FailDirectory = Path.Combine(processInfo.InstallPath, "fail", processInfo.LastVersion),
54+
BackupDirectory = Path.Combine(processInfo.InstallPath, processInfo.LastVersion),
55+
ExtendedField = processInfo.LastVersion
56+
};
3657
}
37-
38-
public void Launch() => _strategy.Launch();
3958
}

src/c#/GeneralUpdate.Bowl/GeneralUpdate.Bowl.csproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@
2525
<None Update="Applications\Linux\procdump_3.3.0_amd64.deb">
2626
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2727
</None>
28+
<None Update="Applications\Windows\export.bat">
29+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
30+
</None>
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<PackageReference Include="System.Text.Json" Version="9.0.0" />
35+
</ItemGroup>
36+
37+
<ItemGroup>
38+
<ProjectReference Include="..\GeneralUpdate.Common\GeneralUpdate.Common.csproj" />
2839
</ItemGroup>
2940

3041
</Project>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System.Collections.Generic;
2+
using GeneralUpdate.Bowl.Strategys;
3+
4+
namespace GeneralUpdate.Bowl.Internal;
5+
6+
internal class Crash
7+
{
8+
public MonitorParameter Parameter { get; set; }
9+
10+
public List<string> ProcdumpOutPutLines { get; set; }
11+
}

0 commit comments

Comments
 (0)