$npx -y skills add wshaddix/dotnet-skills --skill dotnet-build-analysisInterpreting MSBuild output, NuGet errors, or analyzer warnings. Error codes, CI drift fixes.
| 1 | # dotnet-build-analysis |
| 2 | |
| 3 | ## Overview / Scope Boundary |
| 4 | |
| 5 | Help agents interpret and act on MSBuild build output. Covers error code prefixes, NuGet restore failures, analyzer warning interpretation, multi-targeting build differences, and "works locally, fails in CI" diagnosis patterns. Each subsection includes example output, diagnosis steps, and a fix pattern. |
| 6 | |
| 7 | **Out of scope:** Writing or modifying .csproj files (owned by [skill:dotnet-csproj-reading]). Project structure decisions (owned by [skill:dotnet-project-structure]). Common agent code mistakes (owned by [skill:dotnet-agent-gotchas]). |
| 8 | |
| 9 | ## Prerequisites |
| 10 | |
| 11 | .NET 8.0+ SDK. MSBuild (included with .NET SDK). Understanding of SDK-style project format. |
| 12 | |
| 13 | Cross-references: [skill:dotnet-agent-gotchas] for common code mistakes that cause build errors, [skill:dotnet-csproj-reading] for project file structure and modification, [skill:dotnet-project-structure] for project organization and SDK selection. |
| 14 | |
| 15 | --- |
| 16 | |
| 17 | ## Error Code Prefixes |
| 18 | |
| 19 | MSBuild output uses standardized prefixes to indicate the error source. Understanding the prefix tells you which system produced the error and where to look for fixes. |
| 20 | |
| 21 | ### CS -- C# Compiler Errors and Warnings |
| 22 | |
| 23 | Produced by the Roslyn C# compiler. These are language-level issues in source code. |
| 24 | |
| 25 | **Example output:** |
| 26 | |
| 27 | ``` |
| 28 | src/MyApp.Api/Services/OrderService.cs(42,17): error CS0246: The type or namespace name 'OrderDto' could not be found (are you missing a using directive or an assembly reference?) |
| 29 | src/MyApp.Api/Models/User.cs(15,9): warning CS8618: Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable. |
| 30 | ``` |
| 31 | |
| 32 | **Diagnosis:** |
| 33 | 1. Parse the file path and line number from the error -- `src/MyApp.Api/Services/OrderService.cs` line 42, column 17. |
| 34 | 2. CS0246 means a type is missing. Check: is the type defined? Is the namespace imported? Is the project referencing the assembly that contains it? |
| 35 | 3. CS8618 is a nullable reference type warning. The property needs a `required` modifier, nullable annotation (`string?`), or constructor initialization. |
| 36 | |
| 37 | **Fix pattern:** |
| 38 | - CS0xxx (syntax/type errors): Fix source code at the indicated location. Add `using` directives, fix type names, add missing references. |
| 39 | - CS8xxx (nullable warnings): Add null annotations, null checks, or `required` modifiers. Do NOT suppress with `#pragma` or `!` operator. |
| 40 | |
| 41 | ### MSB -- MSBuild Engine Errors |
| 42 | |
| 43 | Produced by the MSBuild build engine itself. These indicate project file problems, target failures, or build system misconfiguration. |
| 44 | |
| 45 | **Example output:** |
| 46 | |
| 47 | ``` |
| 48 | error MSB4019: The imported project "C:\Program Files\dotnet\sdk\9.0.100\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the expression in the Import declaration "..." is correct. |
| 49 | error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. You might need to install the developer pack for this framework version. |
| 50 | ``` |
| 51 | |
| 52 | **Diagnosis:** |
| 53 | 1. MSB4019: An MSBuild `.targets` file is missing. This usually means wrong SDK type, missing workload, or corrupt SDK installation. |
| 54 | 2. MSB3644: Targeting a framework version whose targeting pack is not installed. Common when a project targets .NET Framework but only .NET (Core) SDK is installed. |
| 55 | |
| 56 | **Fix pattern:** |
| 57 | - MSB4019: Verify `<Project Sdk="...">` is correct (e.g., `Microsoft.NET.Sdk.Web` for ASP.NET Core). Run `dotnet workload list` and install missing workloads. |
| 58 | - MSB3xxx: Check `<TargetFramework>` value. Ensure the required SDK or targeting pack is installed. |
| 59 | |
| 60 | ### NU -- NuGet Errors and Warnings |
| 61 | |
| 62 | Produced by the NuGet package manager during restore or pack operations. |
| 63 | |
| 64 | **Example output:** |
| 65 | |
| 66 | ``` |
| 67 | error NU1101: Unable to find package Newtonsoft.Json.Extensions. No packages exist with this id in source(s): nuget.org |
| 68 | warning NU1603: Microsoft.EntityFrameworkCore 9.0.0 depends on Microsoft.Extensions.Caching.Memory (>= 9.0.0) but version Microsoft.Extensions.Caching.Memory 8.0.1 was resolved. Approve the package to suppress this warning. |
| 69 | error NU1605: Detected package downgrade: Microsoft.Extensions.Logging from 9.0.0 to 8.0.1. Reference the package directly from the project to select a different version. |
| 70 | ``` |
| 71 | |
| 72 | **Diagnosis:** |
| 73 | 1. NU1101: Package ID does not exist. Check spelling, verify the package source is configured, check if the package was renamed or deprecated. |
| 74 | 2. NU1603: Transitive dependency version conflict. A package wants a newer version than what is resolved. |
| 75 | 3. NU1605: Explicit downgrade detected. Two packages require different versions of the same dependency. |
| 76 | |
| 77 | **Fix pattern:** |
| 78 | - NU1101: Fix the package name. Search [nuget.org](https://www.nuget.org/) for the correct ID. |
| 79 | - NU1603/NU1605: Add a direct `<PackageReference>` for the conflicting package at a com |