aL1CesT 7379571e2d build(desktop): 默认开启裁剪,体积从 108 MB 降到 51 MB
桌面端以前发布出来是 107.8 MB(单文件 exe 90.3 MB),其中绝大部分是随包携带的
.NET 运行时里用不到的部分。这次让 `dotnet publish -r <rid>` 默认打开裁剪:

    默认(裁剪)      51.3 MB   exe 33.9 MB
    加压缩            36.9 MB   exe 19.5 MB
    -p:PublishTrimmed=false   107.7 MB   exe 90.3 MB(和以前一样)

选择不裁剪的方式就是发布时加 `-p:PublishTrimmed=false`,输出与改动前完全一致。
普通 `dotnet build`(不带 RID)不受影响,因为裁剪需要 RID 才有意义。

裁剪在这里不是免费的,新增的 ILLink.Descriptors.xml 就是为了付这笔账。有两处
东西是靠反射拿到的,直接裁剪会安静地消失:

1. DI 容器。AutoDependencyInjectExtensions 用 `Assembly.GetTypes()` 扫描
   ZonyLrcTools.Common,把实现 ITransientDependency / ISingletonDependency 的
   类型注册进去。裁剪器看不到这些类型被实例化,会把它们删掉,然后程序能启动、
   一进页面就抛 "No service for type ... has been registered"。

2. Avalonia 的自动化 peer。Windows UI Automation 是按名字请求节点的,裁剪掉之后
   窗口照常渲染,但 UIA 树是空的 —— 读屏软件、讲述人、以及任何自动化脚本看到的
   都是一个空壳。

第 2 点踩过一次坑值得记下来:只保留 Avalonia.Controls 不够。第一版裁出来的 exe
能启动、界面完整,但 UIA 枚举返回 0 个元素。真正的 UIA provider 在 Win32 后端里,
通过 COM 激活而不是静态引用,所以要额外保留 Avalonia.Win32 和 Avalonia.Base。
补上之后 UIA 树恢复成 39 个元素,与不裁剪版本完全一致。

TrimMode 用 partial:只丢弃整个未被引用的程序集,不裁剪方法体。体积收益主要来自
框架,这样做不会去赌"某个方法没被反射用到"。

另外 ILLink.Descriptors.xml 里写的是程序集名不是包名 —— MusicDecrypto.Library
这个包发出的程序集叫 libmusicdecrypto,写包名会得到 IL2007 警告且不生效。

CI 的 Verify 步骤加了一条 90 MB 上限断言:裁剪可以被环境变量或命令行静默关掉,
而关掉之后唯一的症状就是包大了 55 MB,没人会注意到。用宽阈值而不是精确值是给
框架版本升级留余量。

实测(win-x64 自包含单文件):

    项目            总大小    主 exe    UIA 元素   .kgg 解密   歌词下载
    不裁剪          107.8 MB  90.3 MB   39        3/3         3/3
    裁剪             51.3 MB  33.9 MB   39        3/3         3/3
    裁剪 + 压缩      36.9 MB  19.5 MB   39        3/3         —
    Trimmed=false   107.7 MB  90.3 MB   —         —           —

.kgg 解密产物逐字节相同(3371722 / 51650043 / 48354702 字节);设置写回仍然只改
config.yaml 里受影响的那几行,60 行、35 条注释全保留;五个页面在裁剪版下截图与
不裁剪版无差异。启动耗时略慢:1048 ms → 1223 ms,因为裁剪后的程序集元数据要从
打包数据里反序列化;换来的是下载体积少 56 MB。

这段代码由 AI 辅助编写,发布前已在本机逐项跑过上面这张表。
2026-11-09 05:02:46 +08:00
2026-01-09 00:25:01 +08:00
2022-10-01 14:01:46 +08:00
2026-01-09 00:15:43 +08:00
2021-05-07 10:26:26 +08:00

English | 简体中文

Disclaimer

  • This tool is for personal learning and research purposes only. The executable binary files are for demonstration purposes only and the source code and its products must not be used for commercial purposes. Otherwise, I here will not be responsible for any related legal issues.
  • Any unit or individual that downloads and uses the software resulting in any accidents, negligence, contract breaches, defamation, copyright or intellectual property infringement, and their resulting losses (including but not limited to direct, indirect, incidental or derivative losses), I here will not bear any legal responsibility.
  • Users clearly agree to all the terms listed in this statement and fully assume the risks and consequences of using this tool. I here will not bear any legal responsibility.

Introduction

ZonyLrcToolX 4 is a cross-platform lyrics download tool based on CEF. QQ Group: 337656932. Detailed video tutorials are available in the group files.

🚧 The current version is under development. 🚧 If you want to see working code, please switch to the dev branch.

Download

To get the latest version, please visit the Release page for download.

Arch Linux User Repository

This software has been packaged into AUR. Arch Linux and its derivative distribution users can install it with the following command:

# yay or other AUR Helpers
yay -S zonylrctoolsx-bin

ZonyLrcTools.Cli --help

Usage

Detailed usage instructions have been moved to a new documentation site. Please visit https://docs.myzony.com for complete documentation.

Donation

爱发电

Star History

Star History Chart

S
Description
ZonyLrcToolsX 是一个能够方便地下载歌词的小软件。
Readme MIT
18 MiB
0 Stars 1 Watchers 0 Forks
Languages
C# 99.7%
PowerShell 0.2%
Shell 0.1%