# GeneralUpdate.Avalonia **Repository Path**: GeneralLibrary/GeneralUpdate.Avalonia ## Basic Information - **Project Name**: GeneralUpdate.Avalonia - **Description**: No description available - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-06-15 - **Last Updated**: 2026-06-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GeneralUpdate.Avalonia [![GitHub Stars](https://img.shields.io/github/stars/GeneralLibrary/GeneralUpdate.Avalonia?style=flat-square)](https://github.com/GeneralLibrary/GeneralUpdate.Avalonia/stargazers) [![GitHub Forks](https://img.shields.io/github/forks/GeneralLibrary/GeneralUpdate.Avalonia?style=flat-square)](https://github.com/GeneralLibrary/GeneralUpdate.Avalonia/network/members) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg?style=flat-square)](./LICENSE) [![NuGet](https://img.shields.io/nuget/v/GeneralUpdate.Avalonia.Android?style=flat-square)](https://www.nuget.org/packages/GeneralUpdate.Avalonia.Android/) --- ![](./imgs/banner.png) ## 项目简介 `GeneralUpdate.Avalonia` 是面向 Avalonia 应用的更新能力仓库。当前核心模块为 `GeneralUpdate.Avalonia.Android`,提供 Android 平台自动更新流程编排能力(无 UI),适配 `net10.0-android`,面向 Avalonia 12+ 应用。 项目将更新流程拆分为可组合的抽象接口,便于在不同业务场景下替换版本比较、下载、哈希校验、安装拉起、日志与事件分发实现。 ## 核心特性 - **Android 更新核心(无 UI)**:宿主应用可完全控制弹窗、进度和错误展示。 - **完整更新链路**:版本校验 → 断点续传下载 → SHA-256 校验 → 安装器拉起。 - **可扩展架构**:`IVersionComparer`、`IUpdateDownloader`、`IHashValidator`、`IApkInstaller` 等均可替换。 - **断点续传下载**:支持 sidecar 元数据与流式写入,提升弱网场景稳定性。 - **统一事件通知**:提供验证、进度、完成、失败等事件用于 UI/日志集成。 ## 快速开始 ### 环境准备 - .NET SDK:`10.0+` - 平台:`Android (net10.0-android)` - Avalonia:`12+` - Git:`2.30+` ### 安装步骤 1. 克隆仓库 ```bash git clone https://github.com/GeneralLibrary/GeneralUpdate.Avalonia.git cd GeneralUpdate.Avalonia ``` 2. 安装依赖(以 NuGet 包方式使用) ```bash dotnet add package GeneralUpdate.Avalonia.Android ``` 3. 本地构建与测试(仓库开发) ```bash dotnet test tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj ``` ### 基本使用示例 ```csharp using GeneralUpdate.Avalonia.Android; using GeneralUpdate.Avalonia.Android.Models; var cacheDirPath = Android.App.Application.Context.CacheDir?.AbsolutePath ?? Path.GetTempPath(); var options = new AndroidUpdateOptions { DownloadDirectoryPath = Path.Combine(cacheDirPath, "update"), FileProviderAuthority = "com.example.app.generalupdate.fileprovider" }; using var bootstrap = GeneralUpdateBootstrap.CreateDefault(options); var packageInfo = new UpdatePackageInfo { Version = "2.3.0", DownloadUrl = "https://example.com/app-release.apk", Sha256 = "REPLACE_WITH_ACTUAL_SHA256_HASH", FileName = "app-release.apk" }; var check = await bootstrap.ValidateAsync(packageInfo, "2.2.1", CancellationToken.None); if (check.UpdateFound) { var prepared = await bootstrap.DownloadAndVerifyAsync(packageInfo, CancellationToken.None); if (prepared.Success && prepared.FilePath is not null) { await bootstrap.LaunchInstallerAsync(packageInfo, prepared.FilePath, CancellationToken.None); } } ``` ## 目录结构 ```text GeneralUpdate.Avalonia/ ├── src/ │ └── GeneralUpdate.Avalonia.Android/ # Android 自动更新核心库 ├── tests/ │ └── GeneralUpdate.Avalonia.Android.Tests/ # 单元测试 ├── README.md ├── README-EN.md └── LICENSE ``` ## 贡献指南 欢迎通过 GitHub 协作流程参与贡献: 1. Fork 本仓库并从 `main` 创建分支:`feature/{{short-description}}`。 2. 保持变更聚焦,并遵循现有代码风格与命名规范。 3. 提交前运行现有测试: ```bash dotnet test tests/GeneralUpdate.Avalonia.Android.Tests/GeneralUpdate.Avalonia.Android.Tests.csproj ``` 4. 提交 Pull Request,说明动机、实现方案和兼容性影响。 5. 根据评审反馈迭代,合并后删除分支。 ## 许可证 本项目采用 **Apache License 2.0**。详情请见 [LICENSE](./LICENSE)。 ## 联系方式 - 仓库地址:https://github.com/GeneralLibrary/GeneralUpdate.Avalonia - 问题反馈:https://github.com/GeneralLibrary/GeneralUpdate.Avalonia/issues - 讨论交流:https://github.com/GeneralLibrary/GeneralUpdate.Avalonia/discussions