3gbywork.CommonUtility.StaticResourceUpdater 1.0.1

dotnet add package 3gbywork.CommonUtility.StaticResourceUpdater --version 1.0.1
NuGet\Install-Package 3gbywork.CommonUtility.StaticResourceUpdater -Version 1.0.1
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="3gbywork.CommonUtility.StaticResourceUpdater" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add 3gbywork.CommonUtility.StaticResourceUpdater --version 1.0.1
#r "nuget: 3gbywork.CommonUtility.StaticResourceUpdater, 1.0.1"
#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 3gbywork.CommonUtility.StaticResourceUpdater as a Cake Addin
#addin nuget:?package=3gbywork.CommonUtility.StaticResourceUpdater&version=1.0.1

// Install 3gbywork.CommonUtility.StaticResourceUpdater as a Cake Tool
#tool nuget:?package=3gbywork.CommonUtility.StaticResourceUpdater&version=1.0.1

CommonUtility.StaticResourceUpdater

自动更新器,服务端使用简单的静态页面服务即可

服务端

服务器配置

以 nginx 为例,配置如下:

http {
    # 指定编码,如果在linux中显示中文乱码可以指定此设置
    charset utf-8;

    server {
            listen your port;
            listen [::]:your port;
            server_name localhost;

            location / {
                alias /path/to/versions_folder/;
                access_log on;
                autoindex on;
                autoindex_format json;
                autoindex_exact_size off;
                # autoindex_localtime on; # 只对autoindex_format html生效
            }
    }
}

服务端目录结构

d		1.0.0       #文件夹名称为版本号,文件夹内是需要升级的文件
d		1.1.0

Json示例

[
    {
        "name": "1.3",
        "type": "directory",
        "mtime": "Fri, 22 Sep 2023 06:44:27 GMT"
    }
]

客户端

客户端使用示例

// 示例一 下载远程目录版本
using (var updateService = new StaticResourceUpdateService())
{
    await updateService.DownloadDirectoryAsync(Constants.UpdateBaseUrl, Directory.GetCurrentDirectory(), false);
}

// 示例二 检查服务器最新版本,并于当前版本比较,决定是否更新
using (var updateService = new StaticResourceUpdateService())
{
    var updateUrl = $"{Constants.UpdateBaseUrl}{ModuleName}";
    var newVersion = await updateService.CheckUpdateAsync(updateUrl);
    if (newVersion != null && Version.Parse(newVersion.Name) > version)
    {
        await updateService.DownloadAsync(updateUrl, newVersion, Directory.GetCurrentDirectory(), false);
    }
}
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 164 1/8/2024
1.0.0 112 9/28/2023