如何在Uno Platform上启用XAML热重载功能?
Uno Platform XAML热重载失效与VS Code扩展异常问题
通过dotnet new unoapp创建Uno Platform项目后,遇到两个核心问题:
- XAML/C#代码修改无法触发热重载,必须重建重启才能生效
- Linux系统下的VS Code已安装Uno Platform扩展,但无XAML代码补全提示,怀疑扩展未正常工作是热重载失效的根源
相关环境日志
dotnet --info输出
.NET SDK (reflecting any global.json): Version: 6.0.400 Commit: 7771abd614 Runtime Environment: OS Name: pop OS Version: 22.04 OS Platform: Linux RID: linux-x64 Base Path: /usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.400/ global.json file: Not found Host: Version: 6.0.8 Architecture: x64 Commit: 55fb7ef977 .NET SDKs installed: 6.0.108 [/usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.108] 6.0.400 [/usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.400] .NET runtimes installed: Microsoft.AspNetCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.28 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.8 [/usr/lib/dotnet/dotnet6-6.0.108/shared/Microsoft.NETCore.App] Download .NET: https://aka.ms/dotnet-download Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info
uno-check输出
🚑 Uno Platform Check v1.5.3.0 💉 ──────────────────────────────────────────────────────────────────────────────── This tool will check your Uno Platform development environment. If problems are detected, it will offer the option to try and fix them for you, or suggest a way to fix them yourself. ──────────────────────────────────────────────────────────────────────────────── ⏳ Synchronizing configuration... ok ⏳ Scheduling appointments... ok 🔎 .NET SDK Checkup... – 6.0.108 - /usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.108 – 6.0.400 - /usr/lib/dotnet/dotnet6-6.0.108/sdk/6.0.400 🔎 .NET SDK - Workload Deduplication Checkup... 🔎 GTK3+ Checkup... 🔎 .NET SDK - Workloads (6.0.400-rtm.22364.21) Checkup... ──────────────────────────────────────────────────────────────────────────────── ✔ Congratulations, everything looks great! Press Enter to finish...
WASM运行时控制台日志
fail: Uno.UI.RemoteControl.RemoteControlClient[0] Failed to get remote control server port from the IDE for endpoint 192.168.1.16. dotnet.js line 1 > eval:1:9 fail: Uno.UI.RemoteControl.RemoteControlClient[0] Failed to get remote control server port from the IDE for endpoint [fe80::2a60:daed:fec3:e7dc]. dotnet.js line 1 > eval:1:9 fail: Uno.UI.RemoteControl.RemoteControlClient[0] Failed to get any remote control server endpoint from the IDE.
排查与修复步骤
重置VS Code扩展状态
- 关闭VS Code,删除项目根目录下的
.vscode文件夹 - 重新打开VS Code,卸载Uno Platform扩展后重新安装
- 执行
Developer: Reload Window命令(可通过Ctrl+Shift+P打开命令面板搜索)
- 关闭VS Code,删除项目根目录下的
验证热重载项目配置
- 打开项目的
.csproj文件,确保包含以下配置:<PropertyGroup> <HotReloadProfile>aspnetcore</HotReloadProfile> <EnableHotReload>true</EnableHotReload> <EnableFastUpToDateCheck>false</EnableFastUpToDateCheck> </PropertyGroup> - 使用
dotnet watch run命令启动WASM项目,替代VS Code的默认调试启动方式
- 打开项目的
检查网络与防火墙设置
- 确认系统防火墙允许VS Code监听本地端口,可临时关闭防火墙测试
- 修改项目启动配置,强制使用本地环回地址(127.0.0.1)运行,避免局域网IP的连接问题
更新依赖与工具
- 执行
dotnet tool update -g uno.check更新Uno环境检测工具 - 执行
dotnet new update更新Uno项目模板 - 尝试升级到.NET 7.0或8.0稳定版,重新创建项目测试热重载功能
- 执行
内容的提问来源于stack exchange,提问作者Illian
相关产品推荐
相关产品推荐

