Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,5 @@ GeneralUpdate寓意为通用更新力致于成为全平台更新组件。
| iOS | 暂不支持 |
| Android | 暂不支持 |
| 树莓派(IoT) | 待验证 |
| 麒麟V10(飞腾S2500) | 支持 |
| 麒麟V10(x64) | 支持 |
2 changes: 2 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ GeneralUpdate means that the general update is committed to becoming a full-plat
| iOS | Not currently supported |
| Android | Not currently supported |
| raspberry pie | pending verification |
| Kylin V10 (FT-S2500) | yes |
| Kylin V10 (x64) | yes |
Binary file modified src/c#/.vs/ProjectEvaluation/generalupdate.metadata.v5
Binary file not shown.
Binary file modified src/c#/.vs/ProjectEvaluation/generalupdate.projects.v5
Binary file not shown.
10 changes: 5 additions & 5 deletions src/c#/GeneralUpdate.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,23 @@
app.MapGet("/versions/{clientType}/{clientVersion}/{clientAppKey}", (int clientType, string clientVersion, string clientAppKey, IUpdateService updateService) =>
{
var versions = new List<VersionDTO>();
var md5 = "dd776e3a4f2028a5f61187e23089ddbd";
var md5 = "b03d52c279faf003965c46041f2037f9";//���ɺõĸ��°��ļ���MD5�룬��Ϊ���ظ��ͻ��˵�ʱ����Ҫͬ�������֤�Ƿ����
var pubTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
string version = null;
if (clientType == AppType.ClientApp)
{
//client
//version = "0.0.0.0";
version = "9.9.9.9";
version = "9.9.9.9";//��������Ϊ9���ó�����Ϊ��Ҫ����
}
else if (clientType == AppType.UpgradeApp)
{
//upgrad
//version = "0.0.0.0";
version = "9.9.9.9";
version = "9.9.9.9"; //��������Ϊ9���ó�����Ϊ��Ҫ����
}
var url = $"http://127.0.0.1/1664083126.zip";
var name = "1664081315";
var url = $"http://192.168.50.203/testpacket.zip";//���°������ص�ַ
var name = "testpacket";
versions.Add(new VersionDTO(md5, pubTime, version, url, name));
return updateService.Update(clientType, clientVersion, version, clientAppKey, GetAppSecretKey(), false, versions);
});
Expand Down
102 changes: 71 additions & 31 deletions src/c#/GeneralUpdate.Client/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
using GeneralUpdate.Core.Domain.Entity;
using GeneralUpdate.Core.Domain.Enum;
using GeneralUpdate.Core.Strategys.PlatformAndroid;
using GeneralUpdate.Core.Strategys.PlatformiOS;
using GeneralUpdate.Core.Strategys.PlatformMac;
using GeneralUpdate.Core.Strategys.PlatformWindows;
using GeneralUpdate.Core.Utils;
using System.Text;

namespace GeneralUpdate.Client
Expand All @@ -25,6 +24,7 @@ public MainPage()

private void OnLoaded(object sender, EventArgs e)
{
var md5 = FileUtil.GetFileMD5(@"F:\temp\target\testpacket.zip");
VersionHub<string>.Instance.Subscribe($"{baseUrl}/{hubName}", "TESTNAME", new Action<string>(GetMessage));
}

Expand All @@ -40,32 +40,15 @@ private void Upgrade()
{
Task.Run(async () =>
{
#region Config.

//该对象用于主程序客户端与更新组件进程之间交互用的对象
var config = new Configinfo();
//本机的客户端程序应用地址
config.InstallPath = @"D:\Updatetest_hub\Run_app";
//更新公告网页
config.UpdateLogUrl = "https://www.baidu.com/";
//客户端当前版本号
config.ClientVersion = "1.1.1.1";
//客户端类型:1.主程序客户端 2.更新组件
config.AppType = AppType.ClientApp;
//指定应用密钥,用于区分客户端应用
config.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5";
//更新组件更新包下载地址
config.UpdateUrl = $"{baseUrl}/versions/{config.AppType}/{config.ClientVersion}/{config.AppSecretKey}";
//更新程序exe名称
config.AppName = "AutoUpdate.Core";
//主程序客户端exe名称
config.MainAppName = "AutoUpdate.ClientCore";
//主程序信息
var mainVersion = "1.1.1.1";
//主程序客户端更新包下载地址
config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}";

#endregion update app.
Configinfo configinfo = null;

#if WINDOWS
configinfo = GetWindowsConfiginfo();
#endif

#if ANDROID
configinfo = GetAndroidConfiginfo();
#endif

var generalClientBootstrap = new GeneralClientBootstrap();
//单个或多个更新包下载通知事件
Expand All @@ -81,17 +64,74 @@ private void Upgrade()
//整个更新过程出现的任何问题都会通过这个事件通知
generalClientBootstrap.Exception += OnException;
//ClientStrategy该更新策略将完成1.自动升级组件自更新 2.启动更新组件 3.配置好ClientParameter无需再像之前的版本写args数组进程通讯了。
generalClientBootstrap.Config(baseUrl, "B8A7FADD-386C-46B0-B283-C9F963420C7C").
//generalClientBootstrap.Config(baseUrl, "B8A7FADD-386C-46B0-B283-C9F963420C7C").
generalClientBootstrap.Config(configinfo).
Option(UpdateOption.DownloadTimeOut, 60).
Option(UpdateOption.Encoding, Encoding.Default).
Option(UpdateOption.Format, Format.ZIP).
//注入一个func让用户决定是否跳过本次更新,如果是强制更新则不生效
SetCustomOption(ShowCustomOption).
Strategy<WindowsStrategy>();
SetCustomOption(ShowCustomOption);
#if WINDOWS
generalClientBootstrap.Strategy<WindowsStrategy>();
#endif
#if ANDROID
generalClientBootstrap.Strategy<AndroidStrategy>();
#endif
await generalClientBootstrap.LaunchTaskAsync();
});
}

/// <summary>
/// 获取Windows平台所需的配置参数
/// </summary>
/// <returns></returns>
private Configinfo GetWindowsConfiginfo()
{
//该对象用于主程序客户端与更新组件进程之间交互用的对象
var config = new Configinfo();
//本机的客户端程序应用地址
config.InstallPath = //@"D:\Updatetest_hub\Run_app";
//更新公告网页
config.UpdateLogUrl = "https://www.baidu.com/";
//客户端当前版本号
config.ClientVersion = "1.1.1.1";
//客户端类型:1.主程序客户端 2.更新组件
config.AppType = AppType.ClientApp;
//指定应用密钥,用于区分客户端应用
config.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5";
//更新组件更新包下载地址
config.UpdateUrl = $"{baseUrl}/versions/{config.AppType}/{config.ClientVersion}/{config.AppSecretKey}";
//更新程序exe名称
config.AppName = "AutoUpdate.Core";
//主程序客户端exe名称
config.MainAppName = "AutoUpdate.ClientCore";
//主程序信息
var mainVersion = "1.1.1.1";
//主程序客户端更新包下载地址
config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}";
return config;
}

/// <summary>
/// 获取Android平台所需要的参数
/// </summary>
/// <returns></returns>
private Configinfo GetAndroidConfiginfo()
{
var config = new Configinfo();
config.InstallPath = System.Threading.Thread.GetDomain().BaseDirectory;
//主程序客户端当前版本号
config.ClientVersion = VersionTracking.Default.CurrentVersion.ToString();
config.AppType = AppType.ClientApp;
config.AppSecretKey = "41A54379-C7D6-4920-8768-21A3468572E5";
//主程序客户端exe名称
config.MainAppName = "GeneralUpdate.ClientCore";
//主程序信息
var mainVersion = "1.1.1.1";
config.MainUpdateUrl = $"{baseUrl}/versions/{AppType.ClientApp}/{mainVersion}/{config.AppSecretKey}";
return config;
}

/// <summary>
/// 让用户决定是否跳过本次更新
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions src/c#/GeneralUpdate.Client/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public static MauiApp CreateMauiApp()
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
}).ConfigureEssentials(essentials =>
{
essentials.UseVersionTracking();
});

return builder.Build();
Expand Down
8 changes: 4 additions & 4 deletions src/c#/GeneralUpdate.ClientCore/GeneralClientBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private async Task<GeneralClientBootstrap> BaseLaunch()
}

/// <summary>
/// Configure server address .
/// Configure server address (Recommended Windows,Linux,Mac).
/// </summary>
/// <param name="url">Remote server address.</param>
/// <param name="appName">The updater name does not need to contain an extension.</param>
Expand All @@ -80,8 +80,8 @@ public GeneralClientBootstrap Config(string url,string appSecretKey, string appN
Packet.AppName = appName;
string clienVersion = GetFileVersion(Path.Combine(basePath, $"{Packet.AppName}.exe"));
Packet.ClientVersion = clienVersion;
Packet.AppType = AppType.ClientApp;
Packet.UpdateUrl = $"{url}/versions/{ Packet.AppType }/{ clienVersion }/{ Packet.AppSecretKey }";
Packet.AppType = AppType.UpgradeApp;
Packet.UpdateUrl = $"{url}/versions/{AppType.UpgradeApp}/{ clienVersion }/{ Packet.AppSecretKey }";
//main app.
string mainAppName = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName);
string mainVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
Expand All @@ -96,7 +96,7 @@ public GeneralClientBootstrap Config(string url,string appSecretKey, string appN
}

/// <summary>
/// Custom Configuration.
/// Custom Configuration (Recommended : All platforms).
/// </summary>
/// <param name="info"></param>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyVersion>2.4.7.0</AssemblyVersion>
<FileVersion>2.4.7.0</FileVersion>
<Version>2.4.7</Version>
<Version>2.8.10</Version>
<Authors>juster.chu</Authors>
<Description>Provides functions related to upgrade and update programs.</Description>
<ApplicationIcon>GeneralUpdate.ico</ApplicationIcon>
<PackageIcon>GeneralUpdate128.png</PackageIcon>
<SignAssembly>False</SignAssembly>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<RepositoryUrl>https://github.com/WELL-E/AutoUpdater</RepositoryUrl>
<RepositoryUrl>https://github.com/JusterZhu/GeneralUpdate</RepositoryUrl>
<Copyright>Copyright © 2022</Copyright>
<PackageReleaseNotes>Provides high-performance, low-loss, resume-breakpoint, version-by-version update, binary differential update, incremental update function, configuration file retention update and other features</PackageReleaseNotes>
</PropertyGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/c#/GeneralUpdate.Core/Bootstrap/AbstractBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract class AbstractBootstrap<TBootstrap, TStrategy>

#region Constructors

protected internal AbstractBootstrap() => this._options = new ConcurrentDictionary<UpdateOption, UpdateOptionValue>();
protected internal AbstractBootstrap()=> this._options = new ConcurrentDictionary<UpdateOption, UpdateOptionValue>();

#endregion Constructors

Expand Down Expand Up @@ -115,6 +115,11 @@ protected IStrategy InitStrategy()
return _strategy;
}

protected string GetPlatform()
{
return _strategy.GetPlatform();
}

protected IStrategy ExcuteStrategy()
{
if(_strategy != null) _strategy.Excute();
Expand Down
15 changes: 15 additions & 0 deletions src/c#/GeneralUpdate.Core/Domain/DO/OSSDownloadDO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralUpdate.Core.Domain.DO
{
public class OSSDownloadDO
{
public string Path { get; set; }

public string Url { get; set; }

public string Name { get; set; }
}
}
17 changes: 17 additions & 0 deletions src/c#/GeneralUpdate.Core/Domain/DO/VersionConfigDO.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralUpdate.Core.Domain.DO
{
public class VersionConfigDO
{
public string Url { get; set; }

public string MD5 { get; set; }

public string PacketName { get; set; }

public string Version { get; set; }
}
}
10 changes: 0 additions & 10 deletions src/c#/GeneralUpdate.Core/Domain/DO/VersionDO.cs

This file was deleted.

25 changes: 25 additions & 0 deletions src/c#/GeneralUpdate.Core/Download/DownloadOSS.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using GeneralUpdate.Core.CustomAwaiter;
using GeneralUpdate.Core.Domain.DO;
using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralUpdate.Core.Download
{
public class DownloadOSS : AbstractTask<OSSDownloadDO>
{
private string _url, _name, _targetPath;

public DownloadOSS(string url,string name,string targetPath)
{
_url = url;
_name = name;
_targetPath = targetPath;
}

public void Dowload()
{
DownloadFileRange(_name,_url, _targetPath);
}
}
}
12 changes: 12 additions & 0 deletions src/c#/GeneralUpdate.Core/Exceptions/CustomArgs/ExceptionArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralUpdate.Core.Exceptions.CustomArgs
{
[Serializable]
public abstract class ExceptionArgs
{
public virtual string Message { get { return String.Empty; } }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace GeneralUpdate.Core.Exceptions.CustomArgs
{
[Serializable]
public sealed class PatchDirtyExceptionArgs : ExceptionArgs
{
private readonly String _patchPath;

public PatchDirtyExceptionArgs(String patchPath) { _patchPath = patchPath; }

public String PatchPath { get { return _patchPath; } }

public override string Message
{
get
{
return (_patchPath == null) ? base.Message : $"Patch file path {_patchPath}";
}
}
}
}
Loading