Skip to content

build(deps): pin ReactiveUI.Avalonia to AtomUI's version, ship ReadyToRun Windows builds - #15

Merged
xiaochengzjc merged 2 commits into
masterfrom
fix/reactiveui-version-alignment
Dec 1, 2026
Merged

xiaochengzjc merged 2 commits into
masterfrom
fix/reactiveui-version-alignment

Conversation

@xiaochengzjc

Copy link
Copy Markdown
Collaborator

问题

AtomUI.Desktop.Controls 6.3.x 的 nuspec 声明 ReactiveUI.Avalonia >= 12.0.3,即它是对着 ReactiveUI 23.2.28 编译的 —— 那个版本里 IViewFor 在 ReactiveUI 命名空间。PR #8(.NET 11 升级)把适配器提到 12.1.9,连锁拉进 ReactiveUI 28,而 28 把 IViewFor 挪到了 ReactiveUI.Binding。

结果 AtomUI 的 IL 引用了一个发不出来的类型:

crossgen2: Failed to load type 'ReactiveUI.IViewFor'

所有 PublishReadyToRun 和 PublishAot 发布会直接失败;运行时也埋着一颗雷 —— 任何走到 view locator 的 AtomUI 路径都会 TypeLoadException。

改动

  1. CxShell.csproj:ReactiveUI.Avalonia 12.1.9 → 12.0.3(AtomUI 声明的版本),并加注释说明必须和 AtomUI 一起升。项目自身只在 Program.cs 调用 .UseReactiveUI(),没有 XAML/代码依赖 ReactiveUI 类型,降版无接口损失。
  2. .github/workflows/release.yml:Windows 发布加 -p:PublishReadyToRun=true -p:EnableCompressionInSingleFile=true。

验证

  • 编译 0 警告;dotnet test 790/790 通过。
  • -p:PublishReadyToRun=true 发布成功,crossgen2 不再报错。
  • ReactiveUI.Avalonia 12.0.3 + Avalonia 12.2.0 实测能正常启动到主窗口,无缺方法异常。

启动耗时(win-x64,进程启动到主窗口可见,4 次取样):

形态 体积 启动
现状:单文件 162.6 MB 4.14–4.23 s
R2R 单文件 313.2 MB 1.56–1.65 s
R2R + 单文件压缩 127.0 MB 2.07–2.13 s

压缩比不压缩慢约 0.5 s(首次运行需解包到缓存目录),但体积比现在的发布还小 22%,是唯一「又小又快」的组合。Linux/macOS 保持原样:它们发的是目录而不是单文件,R2R 会让 payload 涨约 25%,没有压缩来抵消。

zhangruochu added 2 commits November 30, 2026 23:54
…gainst

AtomUI.Desktop.Controls 6.3.x declares ReactiveUI.Avalonia 12.0.3, i.e. it is
built against ReactiveUI 23.2.x where IViewFor lives in the ReactiveUI
namespace. PR #8 (.NET 11 upgrade) moved the adapter to 12.1.9, which pulls
ReactiveUI 28 and moved IViewFor to ReactiveUI.Binding, so AtomUI's IL
references a type the shipped assembly no longer contains:

  crossgen2: Failed to load type 'ReactiveUI.IViewFor'

That broke every ReadyToRun and NativeAOT publish, and left a latent
TypeLoadException for any AtomUI path that touches the view locator.

Pin the adapter back to AtomUI's declared dependency so both sides agree.
Verified: build 0 warnings, 790/790 tests, R2R publish succeeds, app reaches
the main window with Avalonia 12.2.0.
Now that ReactiveUI.Avalonia matches AtomUI, crossgen2 compiles the full
dependency graph again, so the Windows artifact can be ReadyToRun.

Measured on win-x64 (time from process start to a visible main window,
warm cache, 4 runs):

  plain single-file             162.6 MB   4.14-4.23 s
  R2R single-file               313.2 MB   1.56-1.65 s
  R2R single-file + compression 127.0 MB   2.07-2.13 s

Compression costs ~0.5 s at launch but keeps the artifact 22% smaller than
the current release, so R2R + compression is the only variant that is both
faster and smaller. Linux and macOS keep the plain publish for now: they
publish a loose directory rather than a single file, where R2R grows the
payload ~25% with no compression to claw it back.
@xiaochengzjc
xiaochengzjc merged commit 91846e9 into master Dec 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant