maui-hot-reload-diagnostics

用于诊断和排查 .NET MAUI 热重载问题的指南,涵盖 C# 热重载、XAML 热重载、Blazor Hybrid、各种 UI 方法(XAML、MauiReactor、C# Markup、Blazor Hybrid)、Visual Studio 与 VS Code 配置、环境变量、编码要求及 MetadataUpdateHandler。适用于热重载不工作、XAML/C# 热重载、UI 未更新、热重载故障排查、MetadataUpdateHandler、Blazor Hybrid 热重载与 DOTNET_WATCH 相关问题。非一般构建错误、应用生命周期或性能分析方案。

仓库最近推送
GitHub Stars
181
Forks
21
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "maui-hot-reload-diagnostics":https://skillpi.com/zh/skills/deepskill-9688001e5a6509fa542fea47683022c2991100d64edf025efa54be74f321d361。安装前核对上游来源和版本:https://github.com/davidortinau/maui-skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

用于诊断和排查 .NET MAUI 热重载问题的指南,涵盖 C# 热重载、XAML 热重载、Blazor Hybrid、各种 UI 方法(XAML、MauiReactor、C# Markup、Blazor Hybrid)、Visual Studio 与 VS Code 配置、环境变量、编码要求及 MetadataUpdateHandler。适用于热重载不工作、XAML/C# 热重载、UI 未更新、热重载故障排查、MetadataUpdateHandler、Blazor Hybrid 热重载与 DOTNET_WATCH 相关问题。非一般构建错误、应用生命周期或性能分析方案。

0 下载

介绍来源: third_party · davidortinau · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
软件、账号及付费要求
翻译待完成,请参阅来源文档。
限制与区别
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: maui-hot-reload-diagnostics
description: >
  Diagnose and troubleshoot .NET MAUI Hot Reload issues (C# Hot Reload, XAML Hot Reload,
  Blazor Hybrid). Covers all UI approaches (XAML, MauiReactor, C# Markup, Blazor Hybrid),
  Visual Studio, VS Code, environment variables, encoding requirements, and MetadataUpdateHandler.
  USE FOR: "hot reload not working", "XAML hot reload", "C# hot reload", "UI not updating",
  "hot reload troubleshooting", "MetadataUpdateHandler", "hot reload Blazor Hybrid",
  "hot reload VS Code", "DOTNET_WATCH".
  DO NOT USE FOR: general build errors (not hot reload related), app lifecycle events
  (use maui-app-lifecycle), or performance profiling (use maui-performance).

.NET MAUI Hot Reload Diagnostics

Systematically diagnose Hot Reload failures for .NET MAUI apps.

Quick diagnosis checklist

  1. Identify what's failing: XAML Hot Reload (.xaml changes) vs C# Hot Reload (.cs changes)
  2. Check run configuration: Must be Debug config, started with F5/debugger attached
  3. Save file and re-execute code path: C# changes require re-triggering the code
  4. Check Hot Reload output: View > Output > "Hot Reload" (VS) or "C# Hot Reload" (VS Code)

⚠️ File encoding requirement

CRITICAL: All .cs files must be UTF-8 with BOM encoding.

# Check if file has BOM (should show "UTF-8 Unicode (with BOM)")
file -I *.cs

# Find files without BOM
find . -name "*.cs" -exec sh -c 'head -c 3 "$1" | od -An -tx1 | grep -q "ef bb bf" || echo "$1"' _ {} \;

# Fix: convert to UTF-8 with BOM
sed -i '1s/^\(\xef\xbb\xbf\)\?/\xef\xbb\xbf/' file.cs
# Or in VS Code: Open file > Save with Encoding > UTF-8 with BOM

Common issues and fixes

"Nothing happens when I save"

  1. Verify Debug configuration (not Release)
  2. Check Hot Reload output for errors
  3. Ensure file is saved (not just modified)
  4. Re-execute the code path (navigate again, tap button again)

"Unsupported edit" / "Rude edit"

Some changes always require app restart:

  • Adding/removing methods, fields, properties
  • Changing method signatures
  • Modifying static constructors
  • Changes to generics

XAML changes don't apply (iOS)

  • ⚠️ Set Linker to Don't Link in iOS build settings
  • Config must be named exactly Debug
  • Don't use XamlCompilationOptions.Skip

Changes apply but UI doesn't update

  • For C#: Must re-trigger the code (re-navigate, re-tap)
  • Check for cached binding values or state
  • Verify you're editing the correct target framework file

Framework-specific pitfalls

MauiReactor v3+

<!-- ✅ Correct — feature switch in .csproj -->
<ItemGroup Condition="'$(Configuration)'=='Debug'">
  <RuntimeHostConfigurationOption Include="MauiReactor.HotReload" Value="true" Trim="false" />
</ItemGroup>
// ❌ Wrong — v2 API, remove for v3+
.EnableMauiReactorHotReload()

⚠️ If migrating from MauiReactor v2, remove the EnableMauiReactorHotReload() call from MauiProgram.cs.

C# Markup (CommunityToolkit.Maui.Markup)

Key points — missing any of these breaks hot reload:

  • ⚠️ Extract UI building into a separate Build() method
  • ⚠️ Implement ICommunityToolkitHotReloadHandler on any page/view needing refresh
  • The OnHotReload() method is called automatically after C# hot reload
  • Must call .UseMauiCommunityToolkitMarkup() in MauiProgram.cs

Blazor Hybrid limitations

These changes always require restart:

  • Adding new components
  • Modifying @inject services
  • Static asset changes (images, fonts)
  • Changes to Program.cs or MauiProgram.cs

These usually work without restart:

  • Razor markup and C# code block changes
  • CSS changes (may need hard refresh if cached)
  • Changing component parameters

⚠️ CSS isolation: If .razor.css changes don't apply, verify the isolated CSS file is properly linked.

Decision framework — which hot reload type?

UI approach What reloads Watch out for
XAML .xaml files (instant) Linker must be off on iOS; config must be "Debug"
C# code-behind Method bodies only Must re-trigger code path; rude edits require restart
MauiReactor v3+ Component re-render Need RuntimeHostConfigurationOption, not code call
C# Markup Build() method body Must implement ICommunityToolkitHotReloadHandler
Blazor Hybrid .razor + .css New components/services need restart

Debugging tips

  • ⚠️ Always check the Hot Reload output window first — it tells you exactly why a change was rejected.
  • Enable detailed logging with env vars before launching IDE (see references/hot-reload-setup.md).
  • Binary logs (dotnet build -bl:build.binlog) help diagnose build-related hot reload failures.
  • When reporting bugs, include: dotnet --info, workload list, binary log, and Hot Reload output.

Quick checklist

  • [ ] Debug configuration selected (not Release)
  • [ ] Debugger attached (F5, not Ctrl+F5)
  • [ ] All .cs files are UTF-8 with BOM
  • [ ] Hot Reload output window checked for errors
  • [ ] Code path re-triggered after C# changes
  • [ ] MauiReactor: RuntimeHostConfigurationOption in .csproj (not code call)
  • [ ] C# Markup: ICommunityToolkitHotReloadHandler implemented
  • [ ] Blazor Hybrid: not changing services/startup code

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 针对 .NET MAUI 热重载这一明确开发痛点,提供系统性诊断流程
  • 覆盖 XAML、C#、MauiReactor、C# Markup、Blazor Hybrid 等多种技术栈
  • 包含快速检查清单和决策框架,实用性强
触发精准90/100

亮点

  • 适用与不适用场景描述清晰,关键词覆盖全面
  • 边界定义明确,避免与其他 Skill 功能重叠
结构规范75/100

待提升项

  • 缺少显式 When to Use 章节标题 原报告严重程度:轻微

    文档内容已涵盖适用场景,但未使用标准章节标题 'When to Use'

    改进建议:建议添加显式的 'When to Use' 章节以提升规范性

亮点

  • Phase/步骤清晰,包含快速检查清单和决策框架
  • 提供了端到端配置示例和常见陷阱说明
执行可靠80/100

待提升项

  • 部分命令缺少安全确认机制说明 原报告严重程度:轻微

    sed -i 等命令直接修改文件,未提醒用户备份或确认

    改进建议:建议在危险操作前添加确认提示或备份建议

亮点

  • 提供了具体的命令行操作和配置示例
  • 覆盖了编码、Linker、框架配置等主要异常场景
  • 工具来源明确,参数正确
证据可验 (前四项均值)83/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

翻译待完成,请参阅来源文档。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。