Hanson.AutoUpdater
3.0.0
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Core 3.1
This package targets .NET Core 3.1. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package Hanson.AutoUpdater --version 3.0.0
NuGet\Install-Package Hanson.AutoUpdater -Version 3.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hanson.AutoUpdater" Version="3.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hanson.AutoUpdater --version 3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Hanson.AutoUpdater, 3.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hanson.AutoUpdater as a Cake Addin #addin nuget:?package=Hanson.AutoUpdater&version=3.0.0 // Install Hanson.AutoUpdater as a Cake Tool #tool nuget:?package=Hanson.AutoUpdater&version=3.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
README
Hanson.AutoUpdater
功能說明
提供導入跨平台更新應用程式的套件
主要功能
- 支援 http/https 的檔案方式進行版本更新
- 啟動 FileUpdate 的更新機制
前置條件
開發環境需具備 .Net6.0 or .Net Core 3.1 or NET 472 or NET 462
運行於 Windows Platform (x86, x64)
運行於 Linux Platform (x86, x64)
運行於 Raspberry PI Platform (x86)
需配合 FileUpdate v2.0.0 以後版本
安裝方式
- 使用 Nuget 方式進行安裝 https://www.nuget.org/packages/hanson.autoupdater/
授權
此專案採用的 License為 Apache-2.0
使用範例
- AutoUpdater 設定檔說明
Config config = new Config
{
// FileUpdate 程式執行檔
AppCommand = "FileUpdate.exe",
// FileUpdate 讀取的設定檔名稱
AppConfigName = "update.json",
// FileUpdate 下載遠端設定檔的 Timeout 時間
HttpClientTimeout = 5000,
// 指定 FileUpdate 存放的相對或絕對路徑 (相對路徑會依進行更新的App資料夾決定)
UpdateExeFolder = @"FileUpdate"
};
- 遠端更新檔範例 (update.json)
{
"app_name": "Sample-App", // app 名稱 (必填)
"app_version": "1.0.1", // app 當前版本 (必填)
"app_restart_command": "Sample-app.exe", // 執行檔名稱及副檔名 (必填)
"app_restart_command_args": "", // 依需求決定執行時是否代入參數
"download_timeout_ms": 10000, // 下載檔案的 timeout 時間 (必填)
"descp": "This is the Sample-App-v1.0.1 software update package.",
"publish_zip_url": "http://127.0.0.1/update/SampleConsoleApp/update.zip", // App 要更新檔案的下載位置 (必填)
"md5": "1EBADE26BB7987E3EAB92797CD98AC60", //package檔案進行 MD5 的檢查碼 (必填)
"required_min_version": "1.0.1", //最小更新版本 (必填)
}
- 自動更新簡易使用範例 ( 在執行路徑下內必須存放 FileUpdate 資料夾 )
private static async Task CheckUpdateAsync()
{
//遠端設定檔的存放位置
var url = "http://127.0.0.1/update/SampleConsoleApp/update.json";
//初始化 自動更新物件 - FileUpdate 資料夾必須存在執行資料夾內
AutoUpdater autoUpdater = new AutoUpdater();
(bool isRunUpdate, UpdateInfo updateInfo) = await autoUpdater.CheckVersionAsync(url);
if (isRunUpdate == default)
{
Console.WriteLine("版本檢查失敗,請確定網路狀態或是遠端伺服器狀態");
}
else
{
if (isRunUpdate)
{
Console.WriteLine("開始執行自動更新作業");
autoUpdater.Start(updateInfo);
}
else
{
Console.WriteLine($"應用程式({updateInfo.AppName}) 版本無需更新");
}
}
}
- Auto Updater 使用設定檔的範例
private static async Task CheckUpdateAsyncUseConfig()
{
//遠端設定檔的存放位置
var url = "http://127.0.0.1/update/SampleConsoleApp/update1.json";
//FileUpdate讀取的設定檔名稱
var configName = $"test.json";
Config config = new Config
{
AppCommand = "FileUpdate.exe",
AppConfigName = configName,
HttpClientTimeout = 10000,
UpdateExeFolder = @"C:\temp\FileUpdate"
};
AutoUpdater autoUpdater = new AutoUpdater(config);
(bool isRunUpdate, UpdateInfo updateInfo) = await autoUpdater.CheckVersionAsync(url);
if (isRunUpdate == default)
{
Console.WriteLine("版本檢查失敗,請確定網路狀態或是遠端伺服器狀態");
}
else
{
if (isRunUpdate)
{
Console.WriteLine("開始執行自動更新作業");
autoUpdater.Start(updateInfo);
}
else
{
Console.WriteLine($"應用程式({updateInfo.AppName}) 版本無需更新");
}
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.1 is compatible. |
.NET Framework | net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.1
- Hanson.Common.Extensions (>= 1.0.0)
- Hanson.Common.FileUtils (>= 1.0.0)
- Hanson.Common.HttpUtils (>= 1.0.0)
- Hanson.Common.SystemUtils (>= 1.0.0)
-
.NETFramework 4.6.2
- Hanson.Common.Extensions (>= 1.0.0)
- Hanson.Common.FileUtils (>= 1.0.0)
- Hanson.Common.HttpUtils (>= 1.0.0)
- Hanson.Common.SystemUtils (>= 1.0.0)
-
.NETFramework 4.7.2
- Hanson.Common.Extensions (>= 1.0.0)
- Hanson.Common.FileUtils (>= 1.0.0)
- Hanson.Common.HttpUtils (>= 1.0.0)
- Hanson.Common.SystemUtils (>= 1.0.0)
-
net6.0
- Hanson.Common.Extensions (>= 1.0.0)
- Hanson.Common.FileUtils (>= 1.0.0)
- Hanson.Common.HttpUtils (>= 1.0.0)
- Hanson.Common.SystemUtils (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.