dotnet-maui-doctor
dotnet-maui-doctor validates and repairs .NET MAUI development environments by detecting the operating system, checking SDK versions against current NuGet requirements, and installing missing workloads and dependencies. Use it when setting up MAUI projects, encountering build failures related to missing SDKs or Android components, or verifying environment health after system updates.
git clone --depth 1 https://github.com/managedcode/dotnet-skills /tmp/dotnet-maui-doctor && cp -r /tmp/dotnet-maui-doctor/catalog/Frameworks/Official-DotNet-MAUI/skills/dotnet-maui-doctor ~/.claude/skills/dotnet-maui-doctorSKILL.md
# .NET MAUI Doctor Validate and fix .NET MAUI development environments. All version requirements are discovered dynamically from NuGet APIs — never hardcode versions. ## When to Use - Setting up a new .NET MAUI development environment - Build errors mentioning missing SDKs, workloads, JDK, or Android components - Errors like "Android SDK not found", "Java version", or "Xcode not found" - Verifying environment health after SDK or OS updates ## When Not to Use - Non-MAUI .NET projects (use standard .NET SDK troubleshooting instead) - Xamarin.Forms apps (different toolchain and workload requirements) - Runtime app crashes unrelated to environment setup - App store publishing or signing issues - IDE-specific issues (Visual Studio or VS Code configuration) ## Important: .NET Version Currency Your training data may be outdated regarding .NET versions. .NET ships new major releases annually (November). Always check the releases-index.json (Task 2) to discover the **latest active major release** — do not assume your training data reflects the current version. For example, if you know about .NET 9.0 but the releases index shows .NET 10.0 as active, use .NET 10.0. ## Inputs - A development machine running macOS, Windows, or Linux - Shell access (Bash on macOS/Linux, PowerShell on Windows) - Internet access for NuGet API queries and SDK downloads - Admin/sudo access may be required for installing SDKs and workloads - **Bash prerequisites**: `curl`, `jq`, and `unzip` (macOS/Linux) - **PowerShell prerequisites**: `Invoke-RestMethod` and `System.IO.Compression` (built-in on Windows) ## Behavior - Run through ALL tasks autonomously - Re-validate after each fix - Iterate until complete or no further actions possible - After detecting platform (Task 1), load only the matching platform-specific references ## Workflow ### Task 1: Detect Environment ```bash # macOS sw_vers && uname -m # Windows systeminfo | findstr /B /C:"OS Name" /C:"OS Version" # Linux cat /etc/os-release && uname -m ``` After detection, load the matching platform references: - **macOS**: `references/platform-requirements-macos.md`, `references/installation-commands-macos.md`, `references/troubleshooting-macos.md` - **Windows**: `references/platform-requirements-windows.md`, `references/installation-commands-windows.md`, `references/troubleshooting-windows.md` - **Linux**: `references/platform-requirements-linux.md` ### Task 2: Check .NET SDK ```bash dotnet --info ``` Compare installed vs `latest-sdk` from https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json where `support-phase` is `"active"`. ### Task 3: Check MAUI Workloads | Workload | macOS | Windows | Linux | |----------|-------|---------|-------| | `maui` | Required | Required | ❌ Use `maui-android` | | `maui-android` | Alias | Alias | Required | | `android` | Required | Required | Required | | `ios` | Required | Optional | N/A | ### Task 4: Discover Requirements from NuGet See `references/workload-dependencies-discovery.md` for complete process. Query NuGet for workload manifest → extract `WorkloadDependencies.json` → get: - `jdk.version` range and `jdk.recommendedVersion` - `androidsdk.packages`, `buildToolsVersion`, `apiLevel` - `xcode.version` range ### Task 5: Validate Java JDK **Only Microsoft OpenJDK supported.** Verify `java -version` output contains "Microsoft". See `references/microsoft-openjdk.md` for detection paths. > Use the JDK version recommended by WorkloadDependencies.json (`jdk.recommendedVersion`), ensuring it satisfies the `jdk.version` range. Do not hardcode JDK versions. **JAVA_HOME is NOT required.** .NET MAUI tools auto-detect Microsoft OpenJDK installations from known paths. Do not tell users to set JAVA_HOME — it is unnecessary and risks pointing to a non-Microsoft JDK. | JAVA_HOME state | OK? | Action | |-----------------|-----|--------| | Not set | ✅ | None needed — auto-detection works | | Set to Microsoft JDK | ✅ | None needed | | Set to non-Microsoft JDK | ⚠️ | **Report as anomaly** — let user decide to unset or redirect | ### Task 6: Validate Android SDK Check packages from `androidsdk.packages`, `buildToolsVersion`, `apiLevel` (Task 4). See `references/installation-commands.md` for sdkmanager commands. ### Task 7: Validate Xcode (macOS Only) ```bash xcodebuild -version ``` Compare against `xcode.version` range from Task 4. See `references/installation-commands-macos.md`. ### Task 8: Validate Windows SDK (Windows Only) The Windows SDK is typically installed as part of the .NET MAUI workload or Visual Studio. See `references/installation-commands-windows.md`. ### Task 9: Remediation See `references/installation-commands.md` for all commands. Key rules: - **Workloads**: Always use `--version` flag. Never use `workload update` or `workload repair`. - **JDK**: Only install Microsoft OpenJDK. Do not set JAVA_HOME (auto-detected). - **Android SDK**: Use `sdkmanager` (from Android SDK command-line tools). On Windows use `sdkmanager.bat`. ### Task 10: Re-validate After each fix, re-run the relevant validation task. Iterate until all checks pass. ## Validation A successful run produces: - .NET SDK installed and matches an active release - All required workloads installed with consistent versions - Microsoft OpenJDK detected (`java -version` contains "Microsoft") - All required Android SDK packages installed (per WorkloadDependencies.json) - Xcode version in supported range (macOS only) - Windows SDK detected (Windows only) ### Build Verification (Recommended) After all checks pass, create and build a test project to confirm the environment actually works: ```bash TEMP_DIR=$(mktemp -d) dotnet new maui -o "$TEMP_DIR/MauiTest" dotnet build "$TEMP_DIR/MauiTest" rm -rf "$TEMP_DIR" ``` On Windows, use `$env:TEMP` or `New-TemporaryFile` for the temp directory. If the build succeeds, the environment is verified. If it fails, use the error output to diagnose remaining issues. ### Run Ve
Build, debug, modernize, or review ASP.NET Core applications with correct hosting, middleware, security, configuration, logging, and deployment patterns on current .NET. USE FOR: working on ASP.NET Core apps, services, or middleware; changing auth, routing, configuration, hosting, or deployment behavior; deciding between ASP.NET Core sub-stacks. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Build, upgrade, and operate .NET Aspire 13.3.x application hosts with current CLI, AppHost, ServiceDefaults, integrations, dashboard, testing, and Azure deployment patterns for distributed apps. USE FOR: Aspire.AppHost.Sdk, Aspire.Hosting.*, DistributedApplication.CreateBuilder, WithReference, WaitFor, AddProject, AddRedis, AddPostgres, aspire run, aspire init, aspire. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Build, review, or migrate Azure Functions in .NET with correct execution model, isolated worker setup, bindings, DI, and Durable Functions patterns. USE FOR: working on Azure Functions in .NET; migrating from the in-process model to the isolated worker model; adding Durable Functions, bindings, or host configuration. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Build and review Blazor applications across server, WebAssembly, web app, and hybrid scenarios with correct component design, state flow, rendering, and hosting choices. USE FOR: building interactive web UIs with C# instead of JavaScript; choosing between Server, WebAssembly, or Auto render modes; designing component hierarchies and state. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Maintain or migrate EF6-based applications with realistic guidance on what to keep, what to modernize, and when EF Core is or is not the right next step. USE FOR: EF6 codebases; runtime versus ORM migration decisions; EDMX, code-first, ObjectContext, and legacy data-access review. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Design, tune, or review EF Core data access with proper modeling, migrations, query translation, performance, and lifetime management for modern .NET applications. USE FOR: DbContext, migrations, model configuration, EF queries, tracking, loading, performance, transactions, and EF6 migration decisions. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Build, review, or migrate .NET MAUI applications across Android, iOS, macOS, and Windows with correct cross-platform UI, platform integration, and native packaging assumptions. USE FOR: working on cross-platform mobile or desktop UI in .NET MAUI; integrating device capabilities, navigation, or platform-specific code; migrating Xamarin.Forms or aligning. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.
Use ML.NET to train, evaluate, or integrate machine-learning models into .NET applications with realistic data preparation, inference, and deployment expectations. USE FOR: ML.NET integration; local model training or retraining; inference pipelines, model loading, evaluation, and deployment review. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.