Token导航 LogoToken导航

Agent Skill · 研究检索

dotnet-build-optimization(dotnet 构建优化)

dotnet-build-optimization 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

dotnet-build-optimization 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为接触敏感数据;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 61,288。

总安装 353周安装 15GitHub Stars 15下载 124核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dotnet-build-optimization(dotnet 构建优化)
来源仓库:https://github.com/wshaddix/dotnet-skills
仓库路径:skills/dotnet-build-optimization
安装命令:
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-build-optimization
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-build-optimization

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

dotnet-build-optimization 诊断增量构建失败和并行构建配置问题。适用于大型解决方案构建缓慢的性能调优场景。提供二进制日志分析和缓存优化策略实施指南。需识别缺失 Inputs/Outputs 导致的重建循环问题。建议配合 Structured Log Viewer 可视化分析构建耗时。

来源仓库内路径:skills/dotnet-build-optimization

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-build-op…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

dotnet-build-optimization 怎么安装?

在终端执行 npx skills add https://github.com/wshaddix/dotnet-skills --skill dotnet-build-optimization。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

dotnet-build-optimization 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

dotnet-build-optimization 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

dotnet-build-optimization 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

dotnet-build-optimization 用的人多吗?

公开数据是累计安装 353 次,近一周安装 15 次,下载 124 次,GitHub 15 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

dotnet-build-optimization 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
dotnet-build-optimization

dotnet 构建优化 · 本页

35315接触敏感数据未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

dotnet-build-optimization

Guidance for diagnosing and fixing build performance problems: incremental build failure diagnosis workflows, binary log analysis with MSBuild Structured Log Viewer, parallel build configuration, build caching, and restore optimization. Covers the diagnostic workflow from symptom (full rebuild on every build) through root cause (missing Inputs/Outputs, timestamp corruption, generator side effects) to fix.

Version assumptions:.NET 8.0+ SDK (MSBuild 17.8+). All examples use SDK-style projects.

Scope boundary: This skill owns build optimization and diagnostics -- incremental build failures, binary logs, parallel builds, build caching, and restore optimization. MSBuild error interpretation and CI drift diagnosis is owned by [skill:dotnet-build-analysis]. MSBuild authoring (targets, props, items, conditions) is owned by [skill:dotnet-msbuild-authoring]. Custom task development is owned by [skill:dotnet-msbuild-tasks]. NuGet lock files and Central Package Management configuration is owned by [skill:dotnet-project-structure].

Cross-references: [skill:dotnet-msbuild-authoring] for custom targets, import ordering, and incremental build authoring patterns. [skill:dotnet-msbuild-tasks] for custom task development. [skill:dotnet-build-analysis] for interpreting MSBuild errors, NuGet restore failures, and CI drift diagnosis. [skill:dotnet-project-structure] for lock files, CPM, and nuget.config configuration.


Incremental Build Failure Diagnosis

When a target runs on every build despite no source changes, the build is not incremental. This wastes time and masks real changes. The diagnosis workflow follows a repeatable pattern: detect the symptom, capture a binary log, identify the offending target, determine why incrementality failed, and apply the fix.

Diagnosis Workflow

1. Symptom: Build takes longer than expected, or output says
   "Building target 'X' completely" on every build
2. Capture binary log:  dotnet build /bl
3. Open the .binlog in MSBuild Structured Log Viewer
4. Search for targets that ran (not skipped)
5. Check: Does the target have Inputs/Outputs?
   - No  -> Add Inputs/Outputs (see fix patterns below)
   - Yes -> Compare timestamps: are outputs older than inputs?
           -> Check for volatile writers or missing output files
6. Apply fix, rebuild, verify target is skipped

Step 1: Capture a Binary Log

# Produce msbuild.binlog in the project directory
dotnet build /bl

# Named log file
dotnet build /bl:build-debug.binlog

# Binary log for restore + build (captures full pipeline)
dotnet build /bl -restore

The /bl switch records every MSBuild event -- property evaluations, item lists, target entry/exit, task execution, and timestamps -- into a compact binary format. Binary logs contain full source paths and environment variables; do not commit them to version control or share publicly.

Step 2: Open in MSBuild Structured Log Viewer

Download from msbuildlog.com. Open the .binlog file. Key views:

ViewUse
TimelineSee which targets ran in parallel and how long each took
Target ResultsFilter by "Built" (ran) vs "Skipped" (incremental hit)
SearchFind specific target names, property values, or file paths
PropertiesInspect evaluated property values at any point in the build
ItemsInspect item collections (Compile, Content, etc.) with metadata

Step 3: Find the Non-Incremental Target

In the Structured Log Viewer, search for the target name and check its result. A target that should be incremental but ran fully will show "Building target 'X' completely" with a reason:

  • "Output file does not exist" -- an expected output file is missing or was deleted
  • "Input file is newer than output file" -- a source file changed, or a preceding step rewrote an output
  • No Inputs/Outputs declared -- the target always runs because MSBuild has no way to check freshness

Common Incremental Build Failure Patterns

Missing Inputs/Outputs on Custom Targets

Symptom: Custom target runs on every build.

Root cause: The target has no Inputs/Outputs attributes. Without them, MSBuild runs the target unconditionally.

Fix: Add Inputs and Outputs that reflect the actual files read and written:

<!-- BEFORE: runs every build -->
<Target Name="GenerateVersionFile" BeforeTargets="CoreCompile">
  <WriteLinesToFile File="$(IntermediateOutputPath)Version.g.cs"
                    Lines="[assembly: System.Reflection.AssemblyInformationalVersion("$(Version)")]"
                    Overwrite="true" />
</Target>

<!-- AFTER: only runs when Version property changes (via project file edit) -->
<Target Name="GenerateVersionFile"
        BeforeTargets="CoreCompile"
        Inputs="$(MSBuildProjectFullPath)"
        Outputs="$(IntermediateOutputPath)Version.g.cs">
  <WriteLinesToFile File="$(IntermediateOutputPath)Version.g.cs"
                    Lines="[assembly: System.Reflection.AssemblyInformationalVersion("$(Version)")]"
                    Overwrite="true" />
</Target>

See [skill:dotnet-msbuild-authoring] for full Inputs/Outputs patterns and batching.

File Copy Timestamp Corruption

Symptom: Target re-runs because output file timestamps are always newer than inputs.

Root cause: A Copy task without SkipUnchangedFiles="true" updates the destination timestamp on every copy, even when content is identical.

Fix:

<!-- BEFORE: copies every build, resetting timestamps -->
<Copy SourceFiles="@(ConfigTemplate)"
      DestinationFolder="$(OutputPath)" />

<!-- AFTER: skips unchanged files, preserving timestamps -->
<Copy SourceFiles="@(ConfigTemplate)"
      DestinationFolder="$(OutputPath)"
      SkipUnchangedFiles="true" />

Generators Writing Unconditionally

Symptom: A code generator target runs every build even though inputs have not changed.

Root cause: The generator writes output files unconditionally, updating their timestamps even when content is identical. The next build sees "input newer than output" (because the generator itself is an input to downstream targets).

Fix: Write to a temp file first, then copy only if content differs:

<Target Name="GenerateCode"
        BeforeTargets="CoreCompile"
        Inputs="@(SchemaFile)"
        Outputs="@(SchemaFile->'$(IntermediateOutputPath)%(Filename).g.cs')">
  <!-- Write to temp file -->
  <Exec Command="codegen %(SchemaFile.Identity) -o $(IntermediateOutputPath)%(SchemaFile.Filename).g.cs.tmp" />

  <!-- Copy only if content changed (preserves timestamp when unchanged) -->
  <Copy SourceFiles="$(IntermediateOutputPath)%(SchemaFile.Filename).g.cs.tmp"
        DestinationFiles="$(IntermediateOutputPath)%(SchemaFile.Filename).g.cs"
        SkipUnchangedFiles="true" />
</Target>

Volatile Intermediate Files

Symptom: A target that depends on intermediate outputs re-runs because an earlier target always regenerates those files.

Root cause: An upstream target produces intermediate files (e.g., generated code, resource bundles) without proper Inputs/Outputs, causing those files to be rewritten every build. Downstream targets see them as "changed" and re-run.

Fix: Add Inputs/Outputs to the upstream target. If the upstream target is from the SDK or a NuGet package and cannot be modified, use Touch task to reset timestamps on its outputs to a stable value when content has not changed.


Binary Log Analysis

Capturing Binary Logs

# Basic binary log (outputs msbuild.binlog)
dotnet build /bl

# Named output file
dotnet build /bl:diagnostic.binlog

# Include restore phase
dotnet build /bl -restore

# Detailed verbosity in console + binary log
dotnet build /bl /v:minimal

Binary logs capture everything regardless of the /v: verbosity level. The /v: switch only controls console output. Always use /bl for diagnosis; console verbosity is for quick scanning.

Preprocessed Project View

The -pp (preprocess) switch dumps the fully evaluated project file after all imports, conditions, and property substitutions:

# Dump the preprocessed project to stdout
dotnet msbuild MyApp.csproj -pp

# Redirect to a file for easier reading
dotnet msbuild MyApp.csproj -pp > preprocessed.xml

The preprocessed output shows:

  • All imported .props and .targets files with their source paths
  • Final evaluated property values
  • Complete item lists after all Include/Exclude/Update/Remove operations
  • All target definitions with resolved conditions

Use -pp to answer "where does this property come from?" or "which .targets file defines this target?" without opening a binary log.

Key Diagnostic Searches in Binary Logs

Search queryWhat it reveals
Target name (e.g., CoreCompile)Whether the target ran or was skipped, and why
$property (e.g., $TargetFramework)Evaluated value at each point in the build
File path (e.g., Order.cs)Which targets processed the file and when
"Building target"All targets that ran (not skipped)
"Skipping target"All targets that were skipped (incremental hit)
Warning/error textSource location and build context for diagnostics

Parallel Builds

Solution-Level Parallelism

MSBuild can build independent projects within a solution in parallel using multiple worker nodes:

# Use all available CPU cores (default behavior for dotnet build)
dotnet build

# Explicit: 4 worker nodes
dotnet build /m:4

# Single-threaded (useful for debugging build order issues)
dotnet build /m:1

dotnet build enables /m (multi-process) by default. Each worker node is a separate MSBuild process that builds one project at a time. Projects with no dependency relationship build in parallel.

Graph Build Mode

Graph build (/graph) analyzes the project dependency graph before building and schedules projects for maximum parallelism:

# Graph-aware parallel build
dotnet build /graph

# Graph build with explicit parallelism
dotnet build /graph /m:8

Graph mode advantages over default parallel build:

  • Static scheduling: Determines the full dependency graph upfront instead of discovering dependencies during build
  • Avoids redundant evaluations: Each project is evaluated once, not once per referencing project
  • Better node utilization: Worker nodes receive projects as soon as dependencies are satisfied

Graph mode is particularly effective for large solutions (50+ projects) where the dependency graph has significant parallelism.

BuildInParallel Task Attribute

Individual MSBuild tasks (like MSBuild task) can declare whether they support parallel invocation:

<!-- Build referenced projects in parallel -->
<MSBuild Projects="@(ProjectReference)"
         BuildInParallel="true"
         Targets="Build" />

BuildInParallel="true" allows the MSBuild task to distribute its project list across available worker nodes. This is the mechanism used by solution builds to parallelize project compilation.

Diagnosing Parallel Build Issues

Parallel builds can surface latent issues that serial builds mask:

  1. Race conditions on shared files: Two projects writing to the same output directory simultaneously. Fix: use per-project output directories (the SDK default bin/Debug/$(TargetFramework)/).
  2. Undeclared dependencies: Project A depends on Project B's output but does not declare a <ProjectReference>. Serial builds happen to build B first; parallel builds may build A first. Fix: add explicit <ProjectReference>.
  3. Directory creation races: Multiple projects creating the same intermediate directory. Fix: use MakeDir task with ContinueOnError="true" or ensure each project uses its own $(IntermediateOutputPath).

Use /m:1 to confirm a build works serially, then /m to check for parallelism issues. Binary logs with timeline view show project scheduling and reveal race conditions.


Build Caching and Restore Optimization

NuGet Restore Optimization

NuGet restore is often the slowest build step, especially in CI. These patterns reduce restore time:

# Locked restore: skip resolution if lock file is current
dotnet restore --locked-mode

# Use lock files for deterministic restores
dotnet restore --use-lock-file
<!-- Enable lock files project-wide in Directory.Build.props -->
<PropertyGroup>
  <RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>

Lock file restore (--locked-mode) skips the dependency resolution algorithm entirely, reading the exact versions from packages.lock.json. This is faster and ensures CI uses the same versions that were tested locally. For lock file and CPM configuration details, see [skill:dotnet-project-structure].

SDK Build Caching

The.NET SDK caches several build artifacts to avoid redundant work:

CacheLocationPurpose
NuGet global packages~/.nuget/packages/Downloaded package contents
NuGet HTTP cache~/.local/share/NuGet/http-cache/HTTP response cache for feed queries
MSBuild project result cacheIn-memory (per build session)Skips re-evaluating already-built projects
obj/ intermediate outputPer-project obj/ directoryCompiler state, generated files, timestamps

CI Build Optimization

# GitHub Actions: cache NuGet packages between runs
- name: Cache NuGet packages
  uses: actions/cache@v4
  with:
    path: ~/.nuget/packages
    key: nuget-${{ runner.os }}-${{ hashFiles('**/packages.lock.json') }}
    restore-keys: |
      nuget-${{ runner.os }}-

# Use locked restore for speed and determinism
- name: Restore
  run: dotnet restore --locked-mode

NoWarn and TreatWarningsAsErrors Strategy

Build-level warning configuration affects build time when analyzers are involved:

<!-- Directory.Build.props: set warning policy for all projects -->
<PropertyGroup>
  <TreatWarningsAsErrors>true</TreatWarningsAsErrors>

  <!-- Suppress specific warnings globally (with justification) -->
  <NoWarn>$(NoWarn);CA2007</NoWarn>  <!-- ConfigureAwait: not needed in ASP.NET Core apps -->
</PropertyGroup>

Rules for warning configuration:

  • Enable TreatWarningsAsErrors in Directory.Build.props so local and CI builds behave identically
  • Use NoWarn sparingly and always with inline justification comments
  • Prefer .editorconfig severity rules over NoWarn for per-rule control
  • For detecting misuse of warning suppression, see [skill:dotnet-build-analysis]

Agent Gotchas

  1. Running dotnet build without /bl when diagnosing build issues. Console output at default verbosity omits critical information about why targets ran. Always capture a binary log (/bl) for diagnosis -- it records everything regardless of console verbosity level.
  2. Assuming incremental build works without Inputs/Outputs. A target without Inputs/Outputs runs on every build unconditionally. There is no implicit incrementality in MSBuild -- you must declare what files the target reads and writes. See [skill:dotnet-msbuild-authoring] for the full pattern.
  3. Forgetting SkipUnchangedFiles="true" on Copy tasks. Without this flag, Copy always updates the destination timestamp, which triggers downstream targets to re-run even when file content is identical.
  4. Using /v:diagnostic instead of /bl for build investigation. Diagnostic verbosity floods the console with thousands of lines and is hard to search. Binary logs contain the same information in a structured, searchable format. Use /bl and the Structured Log Viewer instead.
  5. Sharing the .binlog file without reviewing it first. Binary logs contain full file paths, environment variable values, and potentially secrets passed via MSBuild properties. Review or sanitize before sharing externally.
  6. Assuming /m (parallel build) is always faster. For small solutions (fewer than 5 projects), the overhead of spawning worker nodes can exceed the parallelism benefit. Profile with and without /m to confirm. For large solutions, /graph mode provides better scheduling than default /m.
  7. Committing packages.lock.json without using --locked-mode in CI. The lock file is only useful if CI restores in locked mode. Without --locked-mode, NuGet ignores the lock file and resolves normally, defeating the purpose of deterministic restores.
  8. Modifying .csproj properties to fix build performance without checking the binary log first. Many "slow build" issues are caused by a single non-incremental target, not by global build configuration. Diagnose with /bl before making broad configuration changes.

References

平台分布

Codex

35.84%
按下载量换算44

Claude

27.49%
按下载量换算34

Cursor

18.2%
按下载量换算23

Gemini CLI

9.28%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills