跳到正文
Skillpedia
部署与云(DevOps)5.8k · #14653

msbuild

它能做什么

这项技能是处理 .NET 项目中 MSBuild 问题的起点。它帮助排查构建失败、分析缓慢的构建并审阅构建文件,然后为每类问题应用有针对性的指导。适合遇到无法解释的构建问题的开发者。

适用场景

  • ✓当 .NET 构建失败,且错误信息无法说明原因时。
  • ✓当构建很慢,你想找出哪些步骤耗时最多的时候。
  • ✓当你想获得关于自定义构建文件、导入钩子或构建扩展点的建议时。

技能链接

https://github.com/dotnet/skills/blob/main/plugins/dotnet/skills/msbuild/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/dotnet/skills/blob/main/plugins/dotnet/skills/msbuild/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的 .NET 解决方案构建失败,错误信息无法说明原因。你能找出原因吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会判断任务属于故障排查、性能还是审阅,阅读相应的指导,并在提出修复建议之前检查真实的项目和构建证据。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

MSBuild troubleshooting

This is the entry skill. Choose troubleshooting, performance, or authoring review, then read only the relevant local references. The references retain the content and identities of the original MSBuild skills, with correctness fixes; they are not separate skills to activate.

Start with the task and evidence

For tasks that need a checkout, discover the relevant project/solution, shared build files, SDK selection, and repository build instructions in the current workspace. Preserve the original command, working directory, configuration, target framework, runtime identifier, global properties, and target. Ask only for consequential information that cannot be discovered.

An existing .binlog can be the only available artifact. Analyze it before requesting a new build; paths inside it do not prove a checkout exists locally. For a self-contained static review or advisory question, use the supplied XML and relevant references; do not require a checkout, restore, build, or binlog.

For a mixed request, fix correctness before measuring successful builds, and keep authoring review separate from a performance experiment. A failing test assertion after a successful build is not an MSBuild failure.

1. Troubleshoot build issues

Goal: identify the independent root causes and make the smallest repair, not a broad cleanup.

Situation Read Action
A build failed and a binary log exists binlog-failure-analysis Replay the log with MSBuild; connect errors to the responsible project instance, target, and task. Separate root causes from cascading failures.
The failure needs evidence and no matching log exists binlog-generation, then failure analysis Capture the original invocation once, verify the artifact, and analyze it.
A project/build file has incorrect conditions, items, properties, or output paths msbuild-antipatterns Select the relevant catalog entries and check their exceptions before changing anything.
Imports or build hooks are missing, overwritten, or run in the wrong order extension-points Inspect the import contract, discovery order, and packed NuGet layout rather than hiding a required failure.
Outputs are stale or required work is skipped incremental-build Prove which input, output, timestamp, item, or condition makes the decision wrong. Correctness takes priority over speed.

After a repair, rerun the original failing scenario and check affected dependents. If only a log is available, provide an evidence-backed proposed fix and say it was not applied or rebuilt. Do not turn a targeted failure investigation into solution-wide authoring cleanup.

2. Diagnose and improve build performance

Goal: measure the reported scenario, identify its bottleneck, change one cause, and compare equivalent builds without losing required behavior.

  1. Reuse matching measurements. If they are missing, establish the relevant baseline before editing configuration; do not time a failed build as a successful baseline.
  2. Classify evaluation versus target/task execution. Inclusive target totals and dependency waits are not additive wall time or proof of CPU utilization.
  3. Follow the measured branch below. Do not apply every optimization in every reference.
  4. Repeat the same scenario, command, input change, and instrumentation. Report spread/noise and correctness checks; an isolated faster run is not proof of improvement.
Situation Read Keep distinct
No trustworthy before/after measurements, or a baseline/controlled optimization is requested build-perf-baseline Cold-output, warm changed-input, and no-change builds; restore/cache state; ordinary Build versus forced Rebuild.
The expensive work is not yet identified, or compiler/analyzer/reference/restore time dominates build-perf-diagnostics Actual task cost versus orchestration waits, overlapping durations, and missing instrumentation.
Time is spent before target execution, in globs, imports, or property evaluation eval-performance Evaluation versus execution; legitimate versus acciden
常见问题

它会把旧项目转换为 SDK 风格吗?

不会。遗留项目的迁移由另一项技能负责。

它需要我提供代码吗?

对于项目问题,它会查看工作区;对于审阅提供的构建 XML,它只根据该文本工作。

它会做最小的改动吗?

会。它优先选择能解决根本原因的最小修复。

详情

作者的原始描述

Use only for MSBuild failure investigation, build-performance analysis, or review of existing build XML/extension contracts. A plan to convert a working legacy/non-SDK project to SDK style or migrate packages.config is a project-system migration, NOT a build-file review: do not activate, even to check scope. Framework/API upgrades are also excluded. Activate for advisory Import/Exists hook and NuGet packed-import questions even without a checkout or failed build; .csproj/.fsproj/.vbproj/.props/.targets conditions; custom-target inputs/outputs; .binlog capture/replay; failing dotnet build/resto

repo: dotnet/skills

热度

GitHub 星标
5.8k
排名
#14653
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能