@cratis/pi 7.101.0 → 7.103.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/github-actions.instructions.md +17 -0
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +10 -1
- package/package/corpus/harnesses/copilot/instructions/pull-requests.instructions.md +2 -0
- package/package/corpus/harnesses/copilot/instructions/secrets.instructions.md +4 -0
- package/package/corpus/hooks/README.md +11 -1
- package/package/corpus/hooks/scripts/cratis-check-pr.mjs +12 -1
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +79 -23
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +145 -40
- package/package/corpus/rules/github-actions.md +17 -0
- package/package/corpus/rules/profiles.md +10 -1
- package/package/corpus/rules/pull-requests.md +2 -0
- package/package/corpus/rules/secrets.md +4 -0
- package/package/corpus/skills/analyzing-dotnet-performance/LICENSE +23 -0
- package/package/corpus/skills/analyzing-dotnet-performance/NOTICE +36 -0
- package/package/corpus/skills/analyzing-dotnet-performance/SKILL.md +214 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/async-patterns.md +122 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/collections-and-linq.md +220 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/critical-patterns.md +291 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/io-and-serialization.md +135 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/memory-and-strings.md +219 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/regex-patterns.md +95 -0
- package/package/corpus/skills/analyzing-dotnet-performance/references/structural-patterns.md +38 -0
- package/package/corpus/skills/binlog-generation/LICENSE +23 -0
- package/package/corpus/skills/binlog-generation/NOTICE +22 -0
- package/package/corpus/skills/binlog-generation/SKILL.md +129 -0
- package/package/corpus/skills/check-bin-obj-clash/LICENSE +23 -0
- package/package/corpus/skills/check-bin-obj-clash/NOTICE +27 -0
- package/package/corpus/skills/check-bin-obj-clash/SKILL.md +127 -0
- package/package/corpus/skills/check-bin-obj-clash/references/common-causes-and-fixes.md +206 -0
- package/package/corpus/skills/coverage-analysis/LICENSE +23 -0
- package/package/corpus/skills/coverage-analysis/NOTICE +32 -0
- package/package/corpus/skills/coverage-analysis/SKILL.md +198 -0
- package/package/corpus/skills/coverage-analysis/references/guidelines.md +68 -0
- package/package/corpus/skills/coverage-analysis/references/output-format.md +91 -0
- package/package/corpus/skills/coverage-analysis/references/report-generation.md +58 -0
- package/package/corpus/skills/coverage-analysis/references/setup-discovery.md +307 -0
- package/package/corpus/skills/coverage-analysis/scripts/Compute-CrapScores.ps1 +80 -0
- package/package/corpus/skills/coverage-analysis/scripts/CoverageData.ps1 +272 -0
- package/package/corpus/skills/coverage-analysis/scripts/Extract-MethodCoverage.ps1 +65 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/LICENSE +2 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +201 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/build-once-and-shard.md +158 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/caching.md +86 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/flaky-and-hung-jobs.md +70 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +67 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/required-checks-and-path-filters.md +117 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/runner-sizing-and-images.md +65 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/security-and-pinning.md +73 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/sources.md +33 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/test-setup-cost.md +82 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/ci-timings.sh +356 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1003.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1007.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/jobs/1010.json +79 -0
- package/package/corpus/skills/cratis-ci-pipeline-performance/scripts/fixtures/runs.json +102 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/LICENSE +2 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/SKILL.md +244 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/docker-images.md +86 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/dotnet-nuget.md +87 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/go-jvm-python-elixir.md +83 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/npm-yarn.md +78 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/other-environments.md +60 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/references/worked-examples.md +97 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/cratis-local-packages.sh +778 -0
- package/package/corpus/skills/cratis-engineering-local-cross-repo-verification/scripts/npm-restore-check.cjs +109 -0
- package/package/corpus/skills/csharp-refactoring/LICENSE +23 -0
- package/package/corpus/skills/csharp-refactoring/NOTICE +22 -0
- package/package/corpus/skills/csharp-refactoring/SKILL.md +175 -0
- package/package/corpus/skills/csharp-refactoring/references/operation-catalog.md +37 -0
- package/package/corpus/skills/directory-build-organization/LICENSE +23 -0
- package/package/corpus/skills/directory-build-organization/NOTICE +21 -0
- package/package/corpus/skills/directory-build-organization/SKILL.md +205 -0
- package/package/corpus/skills/directory-build-organization/references/common-patterns.md +56 -0
- package/package/corpus/skills/directory-build-organization/references/multi-level-examples.md +167 -0
- package/package/corpus/skills/directory-build-organization/references/targetframework-props-pitfall.md +54 -0
- package/package/corpus/skills/dotnet-aot-compat/LICENSE +23 -0
- package/package/corpus/skills/dotnet-aot-compat/NOTICE +18 -0
- package/package/corpus/skills/dotnet-aot-compat/SKILL.md +265 -0
- package/package/corpus/skills/dotnet-aot-compat/references/polyfills.md +43 -0
- package/package/corpus/skills/dotnet-trace-collect/LICENSE +23 -0
- package/package/corpus/skills/dotnet-trace-collect/NOTICE +65 -0
- package/package/corpus/skills/dotnet-trace-collect/SKILL.md +116 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-monitor.md +97 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect-linux.md +84 -0
- package/package/corpus/skills/dotnet-trace-collect/references/dotnet-trace-collect.md +91 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfcollect.md +200 -0
- package/package/corpus/skills/dotnet-trace-collect/references/perfview.md +141 -0
- package/package/corpus/skills/dotnet-trace-collect/references/tool-selection.md +160 -0
- package/package/corpus/skills/dump-collect/LICENSE +23 -0
- package/package/corpus/skills/dump-collect/NOTICE +40 -0
- package/package/corpus/skills/dump-collect/SKILL.md +97 -0
- package/package/corpus/skills/dump-collect/references/container-dumps.md +412 -0
- package/package/corpus/skills/dump-collect/references/coreclr-dumps.md +108 -0
- package/package/corpus/skills/dump-collect/references/nativeaot-dumps.md +280 -0
- package/package/corpus/skills/eliminate-redundant-restores/LICENSE +23 -0
- package/package/corpus/skills/eliminate-redundant-restores/NOTICE +19 -0
- package/package/corpus/skills/eliminate-redundant-restores/SKILL.md +112 -0
- package/package/corpus/skills/extension-points/LICENSE +23 -0
- package/package/corpus/skills/extension-points/NOTICE +18 -0
- package/package/corpus/skills/extension-points/SKILL.md +248 -0
- package/package/corpus/skills/filter-syntax/LICENSE +23 -0
- package/package/corpus/skills/filter-syntax/NOTICE +17 -0
- package/package/corpus/skills/filter-syntax/SKILL.md +179 -0
- package/package/corpus/skills/including-generated-files/LICENSE +23 -0
- package/package/corpus/skills/including-generated-files/NOTICE +17 -0
- package/package/corpus/skills/including-generated-files/SKILL.md +139 -0
- package/package/corpus/skills/microbenchmarking/LICENSE +23 -0
- package/package/corpus/skills/microbenchmarking/NOTICE +36 -0
- package/package/corpus/skills/microbenchmarking/SKILL.md +131 -0
- package/package/corpus/skills/microbenchmarking/references/bdn-internals-and-tuning.md +143 -0
- package/package/corpus/skills/microbenchmarking/references/comparison-strategies.md +200 -0
- package/package/corpus/skills/microbenchmarking/references/diagnosers-and-exporters.md +150 -0
- package/package/corpus/skills/microbenchmarking/references/project-setup-and-running.md +189 -0
- package/package/corpus/skills/microbenchmarking/references/writing-benchmarks.md +310 -0
- package/package/corpus/skills/msbuild/LICENSE +23 -0
- package/package/corpus/skills/msbuild/NOTICE +55 -0
- package/package/corpus/skills/msbuild/SKILL.md +117 -0
- package/package/corpus/skills/msbuild/references/antipatterns/additional-antipatterns.md +291 -0
- package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md +57 -0
- package/package/corpus/skills/msbuild/references/antipatterns/private-assets.md +29 -0
- package/package/corpus/skills/msbuild/references/binlog-failure-analysis.md +85 -0
- package/package/corpus/skills/msbuild/references/binlog-generation.md +69 -0
- package/package/corpus/skills/msbuild/references/build-perf-baseline.md +493 -0
- package/package/corpus/skills/msbuild/references/build-perf-diagnostics.md +268 -0
- package/package/corpus/skills/msbuild/references/copy-to-output-directory.md +183 -0
- package/package/corpus/skills/msbuild/references/eval-performance.md +190 -0
- package/package/corpus/skills/msbuild/references/extension-points.md +281 -0
- package/package/corpus/skills/msbuild/references/incremental-build.md +365 -0
- package/package/corpus/skills/msbuild/references/msbuild-antipatterns.md +401 -0
- package/package/corpus/skills/orleans/LICENSE +21 -0
- package/package/corpus/skills/orleans/NOTICE +64 -0
- package/package/corpus/skills/orleans/SKILL.md +140 -0
- package/package/corpus/skills/orleans/references/anti-patterns.md +660 -0
- package/package/corpus/skills/orleans/references/configuration-api.md +933 -0
- package/package/corpus/skills/orleans/references/examples.md +66 -0
- package/package/corpus/skills/orleans/references/grain-api.md +784 -0
- package/package/corpus/skills/orleans/references/grains.md +75 -0
- package/package/corpus/skills/orleans/references/hosting.md +71 -0
- package/package/corpus/skills/orleans/references/implementation.md +591 -0
- package/package/corpus/skills/orleans/references/official-docs-index.md +250 -0
- package/package/corpus/skills/orleans/references/patterns.md +811 -0
- package/package/corpus/skills/orleans/references/persistence-api.md +495 -0
- package/package/corpus/skills/orleans/references/primitive-selection.md +35 -0
- package/package/corpus/skills/orleans/references/scheduling-and-services.md +295 -0
- package/package/corpus/skills/orleans/references/serialization-api.md +299 -0
- package/package/corpus/skills/orleans/references/streaming-api.md +396 -0
- package/package/corpus/skills/orleans/references/testing-patterns.md +210 -0
- package/package/corpus/skills/platform-detection/LICENSE +23 -0
- package/package/corpus/skills/platform-detection/NOTICE +17 -0
- package/package/corpus/skills/platform-detection/SKILL.md +230 -0
- package/package/corpus/skills/platform-detection/references/command-mode.md +27 -0
- package/package/corpus/skills/profiling/LICENSE +21 -0
- package/package/corpus/skills/profiling/NOTICE +50 -0
- package/package/corpus/skills/profiling/SKILL.md +144 -0
- package/package/corpus/skills/profiling/references/commands.md +439 -0
- package/package/corpus/skills/profiling/references/patterns.md +586 -0
- package/package/corpus/skills/profiling/references/profiling.md +190 -0
- package/package/corpus/skills/run-tests/LICENSE +23 -0
- package/package/corpus/skills/run-tests/NOTICE +19 -0
- package/package/corpus/skills/run-tests/SKILL.md +305 -0
- package/package/corpus/skills/target-authoring/LICENSE +23 -0
- package/package/corpus/skills/target-authoring/NOTICE +17 -0
- package/package/corpus/skills/target-authoring/SKILL.md +165 -0
- package/package/corpus/skills/vectorization/LICENSE +23 -0
- package/package/corpus/skills/vectorization/NOTICE +17 -0
- package/package/corpus/skills/vectorization/SKILL.md +189 -0
- package/package/profile-catalog.json +87 -1
- package/package.json +3 -2
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
MSBuild troubleshooting
|
|
2
|
+
Copyright (c) .NET Foundation and Contributors
|
|
3
|
+
Licensed under the MIT License. See LICENSE.
|
|
4
|
+
|
|
5
|
+
Upstream source: https://github.com/dotnet/skills/blob/a6bf43ab61967c30919334986515163ab24d7635/plugins/dotnet/skills/msbuild/SKILL.md
|
|
6
|
+
|
|
7
|
+
Changes made by Cratis:
|
|
8
|
+
|
|
9
|
+
LICENSE:
|
|
10
|
+
- Copy upstream MIT license and copyright verbatim.
|
|
11
|
+
|
|
12
|
+
SKILL.md:
|
|
13
|
+
- Lead the description trigger with an explicit "Use when" clause.
|
|
14
|
+
- Normalize frontmatter serialization, add MIT license where absent; preserve name and description.
|
|
15
|
+
- Add marked modification/source comment and applicability/Cratis precedence line.
|
|
16
|
+
- Require analyzer/warnings-as-errors restoration after labelled timing experiments.
|
|
17
|
+
- Add direct conditional pointers for all otherwise-indirect reference/script/asset files: references/antipatterns/additional-antipatterns.md, references/antipatterns/incremental-build-inputs-outputs.md, references/antipatterns/private-assets.md.
|
|
18
|
+
- Rewrite the description to the Cratis shape (what it does, Use when, Not for) and drop references to skills that are not part of this corpus.
|
|
19
|
+
|
|
20
|
+
references/binlog-failure-analysis.md:
|
|
21
|
+
- Render unimported binlog-failure-analysis routing reference as plain topic text.
|
|
22
|
+
|
|
23
|
+
references/build-perf-baseline.md:
|
|
24
|
+
- Render unimported build-perf-baseline routing reference as plain topic text.
|
|
25
|
+
- Qualify analyzer/warning suppression as timing-only; require the real gate restored.
|
|
26
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
27
|
+
|
|
28
|
+
references/build-perf-diagnostics.md:
|
|
29
|
+
- Render unimported build-perf-diagnostics routing reference as plain topic text.
|
|
30
|
+
- Qualify analyzer/warning suppression as timing-only; require the real gate restored.
|
|
31
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
32
|
+
|
|
33
|
+
references/copy-to-output-directory.md:
|
|
34
|
+
- Render unimported copy-to-output-directory routing reference as plain topic text.
|
|
35
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
36
|
+
|
|
37
|
+
references/eval-performance.md:
|
|
38
|
+
- Render unimported eval-performance routing reference as plain topic text.
|
|
39
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
40
|
+
|
|
41
|
+
references/incremental-build.md:
|
|
42
|
+
- Render unimported incremental-build routing reference as plain topic text.
|
|
43
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
44
|
+
|
|
45
|
+
references/msbuild-antipatterns.md:
|
|
46
|
+
- Render unimported msbuild-antipatterns routing reference as plain topic text.
|
|
47
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
48
|
+
|
|
49
|
+
references/antipatterns/additional-antipatterns.md:
|
|
50
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
51
|
+
|
|
52
|
+
references/extension-points.md:
|
|
53
|
+
- Add or normalize the top Contents list from existing headings; preserve section content.
|
|
54
|
+
|
|
55
|
+
NOTICE: Add this attribution, change list, and any download/execution disclosure.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: msbuild
|
|
3
|
+
description: 'Investigates MSBuild build failures, diagnoses build performance, and reviews build XML and extension contracts using binary logs. Use for failing dotnet build, restore, pack, or publish; .binlog capture and replay; project, props, and targets conditions; custom-target inputs/outputs; Import/Exists hooks and packed NuGet imports; slow evaluation, compilation, copying, or no-change builds; and controlled timing comparisons. Not for legacy or non-SDK project migration, framework or package upgrades, SDK installation, C# refactoring, runtime profiling, assertions after a successful build, or non-MSBuild builds.'
|
|
4
|
+
license: MIT
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<!-- Modified by Cratis from dotnet's original (MIT): frontmatter, applicability, navigation and the changes listed in NOTICE. Upstream: https://github.com/dotnet/skills (plugins/dotnet/skills/msbuild/SKILL.md; see NOTICE) -->
|
|
8
|
+
|
|
9
|
+
# MSBuild troubleshooting
|
|
10
|
+
|
|
11
|
+
Cratis rules in `.cratis/ai/rules/` (including `csharp.md`, `specs.csharp.md`, and `orleans.md`) and the `cratis-*` skills win where they differ.
|
|
12
|
+
|
|
13
|
+
This is the entry skill. Choose **troubleshooting**, **performance**, or **authoring review**, then
|
|
14
|
+
read only the relevant local references. The references retain the content and identities of
|
|
15
|
+
the original MSBuild skills, with correctness fixes; they are not separate skills to activate.
|
|
16
|
+
|
|
17
|
+
## Start with the task and evidence
|
|
18
|
+
|
|
19
|
+
For tasks that need a checkout, discover the relevant project/solution, shared build files, SDK
|
|
20
|
+
selection, and repository build instructions in the current workspace. Preserve the original command, working directory,
|
|
21
|
+
configuration, target framework, runtime identifier, global properties, and target.
|
|
22
|
+
Ask only for consequential information that cannot be discovered.
|
|
23
|
+
|
|
24
|
+
An existing `.binlog` can be the only available artifact. Analyze it before requesting a new
|
|
25
|
+
build; paths inside it do not prove a checkout exists locally. For a self-contained static review
|
|
26
|
+
or advisory question, use the supplied XML and relevant references; do not require a checkout,
|
|
27
|
+
restore, build, or binlog.
|
|
28
|
+
|
|
29
|
+
For a mixed request, fix correctness before measuring successful builds, and keep authoring review
|
|
30
|
+
separate from a performance experiment. A failing test assertion after a successful build is not
|
|
31
|
+
an MSBuild failure.
|
|
32
|
+
|
|
33
|
+
## 1. Troubleshoot build issues
|
|
34
|
+
|
|
35
|
+
**Goal:** identify the independent root causes and make the smallest repair, not a broad cleanup.
|
|
36
|
+
|
|
37
|
+
| Situation | Read | Action |
|
|
38
|
+
| --- | --- | --- |
|
|
39
|
+
| A build failed and a binary log exists | [binlog-failure-analysis](references/binlog-failure-analysis.md) | Replay the log with MSBuild; connect errors to the responsible project instance, target, and task. Separate root causes from cascading failures. |
|
|
40
|
+
| The failure needs evidence and no matching log exists | [binlog-generation](references/binlog-generation.md), then [failure analysis](references/binlog-failure-analysis.md) | Capture the original invocation once, verify the artifact, and analyze it. |
|
|
41
|
+
| A project/build file has incorrect conditions, items, properties, or output paths | [msbuild-antipatterns](references/msbuild-antipatterns.md) | Select the relevant catalog entries and check their exceptions before changing anything. |
|
|
42
|
+
| Imports or build hooks are missing, overwritten, or run in the wrong order | [extension-points](references/extension-points.md) | Inspect the import contract, discovery order, and packed NuGet layout rather than hiding a required failure. |
|
|
43
|
+
| Outputs are stale or required work is skipped | [incremental-build](references/incremental-build.md) | Prove which input, output, timestamp, item, or condition makes the decision wrong. Correctness takes priority over speed. |
|
|
44
|
+
|
|
45
|
+
After a repair, rerun the original failing scenario and check affected dependents. If only a log
|
|
46
|
+
is available, provide an evidence-backed proposed fix and say it was not applied or rebuilt.
|
|
47
|
+
Do not turn a targeted failure investigation into solution-wide authoring cleanup.
|
|
48
|
+
|
|
49
|
+
## 2. Diagnose and improve build performance
|
|
50
|
+
|
|
51
|
+
**Goal:** measure the reported scenario, identify its bottleneck, change one cause, and compare
|
|
52
|
+
equivalent builds without losing required behavior.
|
|
53
|
+
|
|
54
|
+
1. Reuse matching measurements. If they are missing, establish the relevant baseline before
|
|
55
|
+
editing configuration; do not time a failed build as a successful baseline.
|
|
56
|
+
2. Classify evaluation versus target/task execution. Inclusive target totals and dependency waits
|
|
57
|
+
are not additive wall time or proof of CPU utilization.
|
|
58
|
+
3. Follow the measured branch below. Do not apply every optimization in every reference.
|
|
59
|
+
4. Repeat the same scenario, command, input change, and instrumentation. Report spread/noise and
|
|
60
|
+
correctness checks; an isolated faster run is not proof of improvement.
|
|
61
|
+
|
|
62
|
+
| Situation | Read | Keep distinct |
|
|
63
|
+
| --- | --- | --- |
|
|
64
|
+
| No trustworthy before/after measurements, or a baseline/controlled optimization is requested | [build-perf-baseline](references/build-perf-baseline.md) | Cold-output, warm changed-input, and no-change builds; restore/cache state; ordinary Build versus forced Rebuild. |
|
|
65
|
+
| The expensive work is not yet identified, or compiler/analyzer/reference/restore time dominates | [build-perf-diagnostics](references/build-perf-diagnostics.md) | Actual task cost versus orchestration waits, overlapping durations, and missing instrumentation. |
|
|
66
|
+
| Time is spent before target execution, in globs, imports, or property evaluation | [eval-performance](references/eval-performance.md) | Evaluation versus execution; legitimate versus accidental project instances. |
|
|
67
|
+
| Content copies or output I/O dominate | [copy-to-output-directory](references/copy-to-output-directory.md) | Copy mode/version support, unchanged copies, and the intended handling of a modified destination. |
|
|
68
|
+
| A second unchanged build recompiles/regenerates, or incremental behavior is broken | [incremental-build](references/incremental-build.md) | Expected invalidation versus missing tracking; changed/added/removed inputs and missing outputs. |
|
|
69
|
+
|
|
70
|
+
Stop when the suspected bottleneck is not supported by evidence, results fall within noise, or
|
|
71
|
+
correctness regresses. Report missing measurements rather than manufacturing a complete baseline.
|
|
72
|
+
|
|
73
|
+
## 3. Review build authoring
|
|
74
|
+
|
|
75
|
+
**Goal:** improve project/build-file structure and extension contracts while preserving behavior.
|
|
76
|
+
This route means MSBuild authoring cleanup, not an implicit framework, package, language,
|
|
77
|
+
or legacy project-system migration.
|
|
78
|
+
|
|
79
|
+
| Requested change | Read | Preserve |
|
|
80
|
+
| --- | --- | --- |
|
|
81
|
+
| Review/clean up project files, shared properties, item declarations, or custom targets | [msbuild-antipatterns](references/msbuild-antipatterns.md) | Intentional overrides, F# source order, required imports, package assets, and actual input/output contracts. |
|
|
82
|
+
| Review/improve hooks, imports, shared-file discovery, or NuGet build extensions | [extension-points](references/extension-points.md) | Prior hooks, evaluation order, direct/transitive consumer behavior, and the packed layout. |
|
|
83
|
+
| Restructure generation or copying as part of cleanup | [incremental-build](references/incremental-build.md) and [copy-to-output-directory](references/copy-to-output-directory.md), as applicable | First-build and no-change behavior, invalidation, generated-item registration, and output completeness. |
|
|
84
|
+
|
|
85
|
+
Record the existing contract before editing. Review only relevant catalog entries; a matching text
|
|
86
|
+
pattern is not proof of a defect. Leave already-correct patterns unchanged. Validate the original
|
|
87
|
+
configurations, relevant consumers, and affected incremental/pack/publish behavior.
|
|
88
|
+
|
|
89
|
+
## Shared evidence and safety
|
|
90
|
+
|
|
91
|
+
- For capture-only requests, use [binlog-generation](references/binlog-generation.md), report the
|
|
92
|
+
new artifact and original exit code, and stop. For analysis, use
|
|
93
|
+
[MSBuild replay](references/binlog-failure-analysis.md#replay-a-binary-log), never binary-file
|
|
94
|
+
text parsing. Replay success and replay duration are not the recorded build's result or duration.
|
|
95
|
+
- Resolve these files relative to this skill. Do not load the original plugin's skills or search
|
|
96
|
+
other installations/checkouts. If a bundled reference is missing, allow one listing of
|
|
97
|
+
`references`, report the gap, and do not pretend its guidance was followed.
|
|
98
|
+
- Do not clean outputs/caches, stop shared build servers, disable diagnostics, change SDKs, or
|
|
99
|
+
serialize builds as generic fixes. Scope any necessary destructive experiment to approved,
|
|
100
|
+
owned outputs. Keep binary and replayed logs local unless sharing is authorized.
|
|
101
|
+
- Distinguish recorded facts from hypotheses. Missing source, log detail, tools, or platform
|
|
102
|
+
support must be reported explicitly, not replaced with assumed values or invented verification.
|
|
103
|
+
|
|
104
|
+
## Completion
|
|
105
|
+
|
|
106
|
+
Return the selected task, the cause/bottleneck or authoring decision, supporting evidence,
|
|
107
|
+
and the minimal change made or proposed. State when no change is needed. Give the exact
|
|
108
|
+
verification and result, distinguishing successful, failed, and not-run checks; performance work
|
|
109
|
+
also needs comparable measurements and uncertainty. Keep the response proportional to the task.
|
|
110
|
+
|
|
111
|
+
> **Cratis:** Only as a labelled timing experiment; restore analyzers and warnings-as-errors and run the real gate before finishing.
|
|
112
|
+
|
|
113
|
+
## Reference navigation
|
|
114
|
+
|
|
115
|
+
- Read references/antipatterns/additional-antipatterns.md when working on additional antipatterns.
|
|
116
|
+
- Read references/antipatterns/incremental-build-inputs-outputs.md when working on incremental build inputs outputs.
|
|
117
|
+
- Read references/antipatterns/private-assets.md when working on private assets.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# Additional MSBuild anti-patterns
|
|
2
|
+
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- AP-16: Exec for string or path operations
|
|
6
|
+
- AP-17: Updating an item before it exists
|
|
7
|
+
- AP-18: Apparently redundant transitive project references
|
|
8
|
+
- AP-19: Side effects during evaluation
|
|
9
|
+
- AP-20: Platform-specific Exec without a platform contract
|
|
10
|
+
- AP-21: An early property condition reads TargetFramework too soon
|
|
11
|
+
- AP-22: Project instances with path-neutral global properties
|
|
12
|
+
- AP-23: Re-injecting a single-targeted project's own framework
|
|
13
|
+
- Quick-reference checklist
|
|
14
|
+
|
|
15
|
+
This continues the original catalog with AP-16 through AP-23. The same rule applies:
|
|
16
|
+
verify the behavior and exceptions before changing a pattern.
|
|
17
|
+
|
|
18
|
+
## AP-16: Exec for string or path operations
|
|
19
|
+
|
|
20
|
+
**Smell:** invoking a shell or another runtime for simple transformations.
|
|
21
|
+
|
|
22
|
+
**Impact:** platform dependence, process overhead, and awkward property capture.
|
|
23
|
+
|
|
24
|
+
```xml
|
|
25
|
+
<!-- BAD: a shell pipeline for a simple transformation. -->
|
|
26
|
+
<Target Name="GetCleanVersion">
|
|
27
|
+
<Exec Command="echo $(Version) | sed 's/-preview//'" ConsoleToMSBuild="true">
|
|
28
|
+
<Output TaskParameter="ConsoleOutput" PropertyName="CleanVersion" />
|
|
29
|
+
</Exec>
|
|
30
|
+
</Target>
|
|
31
|
+
|
|
32
|
+
<!-- GOOD: property functions, where the transformation is the intended contract. -->
|
|
33
|
+
<PropertyGroup>
|
|
34
|
+
<CleanVersion>$(Version.Replace('-preview', ''))</CleanVersion>
|
|
35
|
+
<HasPrerelease>$(Version.Contains('-'))</HasPrerelease>
|
|
36
|
+
<LowerName>$(AssemblyName.ToLowerInvariant())</LowerName>
|
|
37
|
+
<NormalizedOutput>$([MSBuild]::NormalizeDirectory('$(OutputPath)'))</NormalizedOutput>
|
|
38
|
+
<ToolPath>$([MSBuild]::NormalizePath('$(MSBuildThisFileDirectory)', 'tools', 'mytool.exe'))</ToolPath>
|
|
39
|
+
</PropertyGroup>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Preserve transformation semantics and evaluation timing. This does not mean arbitrary external
|
|
43
|
+
tools or stateful operations should become property functions.
|
|
44
|
+
|
|
45
|
+
## AP-17: Updating an item before it exists
|
|
46
|
+
|
|
47
|
+
**Smell:** `Update` is evaluated before the intended item is included.
|
|
48
|
+
|
|
49
|
+
**Impact:** the metadata change matches no existing item.
|
|
50
|
+
|
|
51
|
+
```xml
|
|
52
|
+
<!-- BAD: no matching item exists at the update. -->
|
|
53
|
+
<ItemGroup>
|
|
54
|
+
<Extra Update="external.dat" Visible="false" />
|
|
55
|
+
<Extra Include="external.dat" />
|
|
56
|
+
</ItemGroup>
|
|
57
|
+
|
|
58
|
+
<!-- GOOD: Include then Update in the SAME group is valid. -->
|
|
59
|
+
<ItemGroup>
|
|
60
|
+
<Extra Include="external.dat" />
|
|
61
|
+
<Extra Update="external.dat" Visible="false" />
|
|
62
|
+
</ItemGroup>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The original catalog incorrectly treated mixing Include and Update in one ItemGroup as a
|
|
66
|
+
defect. Order and existence are what matter; splitting groups is neither necessary nor a fix
|
|
67
|
+
for an update that still precedes its include.
|
|
68
|
+
|
|
69
|
+
## AP-18: Apparently redundant transitive project references
|
|
70
|
+
|
|
71
|
+
**Smell:** `App` references both `Core` and `Utils`, and `Core` also references `Utils`.
|
|
72
|
+
|
|
73
|
+
**Impact:** a truly unnecessary edge can add coupling or resolution work, but transitive
|
|
74
|
+
reachability alone does not prove redundancy or an ordering bug.
|
|
75
|
+
|
|
76
|
+
```xml
|
|
77
|
+
<!-- Candidate for review, not automatically incorrect. -->
|
|
78
|
+
<ItemGroup>
|
|
79
|
+
<ProjectReference Include="..\Core\Core.csproj" />
|
|
80
|
+
<ProjectReference Include="..\Utils\Utils.csproj" />
|
|
81
|
+
</ItemGroup>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Keep `App -> Utils` if App uses its API directly, needs its metadata/build-order contract, or
|
|
85
|
+
repository policy requires explicit dependencies. Remove an edge only after verifying equivalent
|
|
86
|
+
compile/runtime/pack behavior and supported SDK/framework configurations. Removing this edge does
|
|
87
|
+
not itself shorten the required `App -> Core -> Utils` reference chain.
|
|
88
|
+
Use [build-perf-baseline](../build-perf-baseline.md) for a measured graph experiment.
|
|
89
|
+
|
|
90
|
+
## AP-19: Side effects during evaluation
|
|
91
|
+
|
|
92
|
+
**Smell:** property evaluation writes files, mutates state, or performs network operations.
|
|
93
|
+
|
|
94
|
+
**Impact:** evaluation can repeat during IDE/design-time and graph discovery, making side effects
|
|
95
|
+
unpredictable. Some such functions are not permitted by default; do not loosen restrictions to
|
|
96
|
+
make a side-effecting property expression work.
|
|
97
|
+
|
|
98
|
+
```xml
|
|
99
|
+
<!-- BAD, and not a generally permitted property function. -->
|
|
100
|
+
<PropertyGroup>
|
|
101
|
+
<Timestamp>$([System.IO.File]::WriteAllText('stamp.txt', 'built'))</Timestamp>
|
|
102
|
+
</PropertyGroup>
|
|
103
|
+
|
|
104
|
+
<!-- Execution-time work belongs in a properly scheduled target. -->
|
|
105
|
+
<Target Name="WriteTimestamp" BeforeTargets="Build">
|
|
106
|
+
<WriteLinesToFile File="stamp.txt" Lines="built" Overwrite="true" />
|
|
107
|
+
</Target>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Moving work to a target still requires deciding its inputs, outputs, and whether it must run
|
|
111
|
+
every time. For evaluation-time read/CPU cost, use [eval-performance](../eval-performance.md).
|
|
112
|
+
|
|
113
|
+
## AP-20: Platform-specific Exec without a platform contract
|
|
114
|
+
|
|
115
|
+
**Smell:** `chmod`, `cmd /c`, or a platform-specific executable is invoked on every OS.
|
|
116
|
+
|
|
117
|
+
**Impact:** the wrong shell/tool or path syntax fails on another platform.
|
|
118
|
+
|
|
119
|
+
```xml
|
|
120
|
+
<Target Name="MakeExecutable" AfterTargets="Build"
|
|
121
|
+
Condition="!$([MSBuild]::IsOSPlatform('Windows'))">
|
|
122
|
+
<Exec Command="chmod +x "$([MSBuild]::NormalizePath('$(OutputPath)', 'mytool'))"" />
|
|
123
|
+
</Target>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Prefer a portable built-in task when equivalent. Otherwise gate supported platforms, quote
|
|
127
|
+
paths, and confirm that skipping the operation on other systems preserves their required behavior.
|
|
128
|
+
An OS condition is not a substitute for implementing a capability the other platform also needs.
|
|
129
|
+
|
|
130
|
+
## AP-21: An early property condition reads TargetFramework too soon
|
|
131
|
+
|
|
132
|
+
**Smell:** a PropertyGroup or property in an early `.props` file conditions on a framework that
|
|
133
|
+
the project body has not set yet.
|
|
134
|
+
|
|
135
|
+
**Impact:** a single-targeted project can silently miss the assignment. A multi-targeted inner
|
|
136
|
+
build may instead receive TargetFramework globally; distinguish those cases.
|
|
137
|
+
|
|
138
|
+
```xml
|
|
139
|
+
<!-- BAD in an early Directory.Build.props when the project sets TargetFramework later. -->
|
|
140
|
+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
|
141
|
+
<DefineConstants>$(DefineConstants);MY_FEATURE</DefineConstants>
|
|
142
|
+
</PropertyGroup>
|
|
143
|
+
|
|
144
|
+
<!-- The same assignment can be placed after the project defines the framework,
|
|
145
|
+
for example in Directory.Build.targets for a single-targeted/inner build. -->
|
|
146
|
+
<PropertyGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
|
147
|
+
<DefineConstants>$(DefineConstants);MY_FEATURE</DefineConstants>
|
|
148
|
+
</PropertyGroup>
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
An outer cross-targeting build may still have no single TargetFramework. Check the intended
|
|
152
|
+
instance, and preserve existing constants rather than replacing them.
|
|
153
|
+
|
|
154
|
+
**Item conditions are different:** items are evaluated after properties. These early-file
|
|
155
|
+
patterns can be correct and must not be flagged merely for using TargetFramework:
|
|
156
|
+
|
|
157
|
+
```xml
|
|
158
|
+
<!-- Valid in Directory.Build.props when the project later sets this framework. -->
|
|
159
|
+
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
|
|
160
|
+
<PackageReference Include="System.Memory" />
|
|
161
|
+
</ItemGroup>
|
|
162
|
+
|
|
163
|
+
<!-- Valid per-framework package version selection. -->
|
|
164
|
+
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
|
165
|
+
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.11" />
|
|
166
|
+
</ItemGroup>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Target conditions are evaluated at execution time. Do not move all item/target conditions just
|
|
170
|
+
because an early **property** condition is wrong.
|
|
171
|
+
|
|
172
|
+
## AP-22: Project instances with path-neutral global properties
|
|
173
|
+
|
|
174
|
+
**Smell:** an MSBuild task builds/publishes the same project, or a referenced project, with an
|
|
175
|
+
extra global property that does not isolate its output paths.
|
|
176
|
+
|
|
177
|
+
```xml
|
|
178
|
+
<!-- Both shapes can create a distinct instance sharing existing bin/obj paths. -->
|
|
179
|
+
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="Publish" Properties="_IsPublishing=true" />
|
|
180
|
+
<MSBuild Projects="..\tool\tool.csproj" Targets="Publish" Properties="_IsPublishing=true" />
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**Impact:** instance identity includes the project path and global properties. Distinct instances
|
|
184
|
+
can write the same assemblies, PDBs, assets files, or generated files, producing duplicated work
|
|
185
|
+
and intermittent parallel-build locks.
|
|
186
|
+
|
|
187
|
+
Confirm the actual global-property differences and evaluated output/intermediate paths using
|
|
188
|
+
[replayed build evidence](../binlog-failure-analysis.md). A property difference alone is not a
|
|
189
|
+
collision if every relevant output is isolated.
|
|
190
|
+
|
|
191
|
+
**Repair choices depend on the build contract:**
|
|
192
|
+
|
|
193
|
+
1. Remove an unnecessary second invocation/property discriminator.
|
|
194
|
+
2. For work that belongs to one instance, schedule a suitable target in that instance, after
|
|
195
|
+
checking its dependency graph for cycles.
|
|
196
|
+
3. Make a producer own its artifacts, and have consumers sequence and consume them rather than
|
|
197
|
+
re-publishing the same project under a different property set.
|
|
198
|
+
4. If different instances are intentional, isolate all relevant outputs/intermediate paths
|
|
199
|
+
early enough for SDK and NuGet consumers, and use matching restore/build settings.
|
|
200
|
+
|
|
201
|
+
**Publish-on-build needs special care.** The original example used a private `_IsPublishing`
|
|
202
|
+
guard and `AfterTargets="Build" DependsOnTargets="Publish"`. That can work through `dotnet build`
|
|
203
|
+
and `dotnet publish` yet produce `MSB4006` through `dotnet msbuild -t:Publish`, because Publish
|
|
204
|
+
already depends on Build. It is not a universal repair.
|
|
205
|
+
|
|
206
|
+
Prefer an explicit publish operation when publish is the requested outcome, choosing an unused
|
|
207
|
+
log name first:
|
|
208
|
+
|
|
209
|
+
```powershell
|
|
210
|
+
dotnet publish .\Tool\Tool.csproj -c Release "-bl:publish-01.binlog"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
If a repository genuinely needs publish-on-build orchestration, validate its target graph and
|
|
214
|
+
all supported entry commands; do not blindly substitute private SDK flags or add a cycle.
|
|
215
|
+
A build-order-only reference can sequence a producer:
|
|
216
|
+
|
|
217
|
+
```xml
|
|
218
|
+
<ProjectReference Include="..\Tool\Tool.csproj" ReferenceOutputAssembly="false" />
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
That reference schedules the producer's **build**, not automatically its Publish target.
|
|
222
|
+
The producer's actual artifact workflow must still exist. Retest the original parallel/graph
|
|
223
|
+
scenario; serialization or repeated cleaning is not a permanent collision fix.
|
|
224
|
+
|
|
225
|
+
## AP-23: Re-injecting a single-targeted project's own framework
|
|
226
|
+
|
|
227
|
+
**Smell:** a reference injects the TFM that a single-targeted project already declares.
|
|
228
|
+
|
|
229
|
+
```xml
|
|
230
|
+
<!-- Tool already declares TargetFramework=net8.0. -->
|
|
231
|
+
<ProjectReference Include="..\Tool\Tool.csproj" SetTargetFramework="TargetFramework=net8.0" />
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
**Impact:** a globally supplied TargetFramework can create an instance different from the ordinary
|
|
235
|
+
build, even though both resolve to the same framework output paths. Confirm that duplicate
|
|
236
|
+
instances actually share paths before attributing file-lock failures to this metadata.
|
|
237
|
+
|
|
238
|
+
```xml
|
|
239
|
+
<!-- Remove the redundant injection when the tool should build as declared. -->
|
|
240
|
+
<ProjectReference Include="..\Tool\Tool.csproj" />
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Do not remove legitimate framework selection:
|
|
244
|
+
|
|
245
|
+
- Selecting one TFM of a multi-targeted reference can be intentional.
|
|
246
|
+
- Overriding a single-targeted reference to a **different** framework can be intentional if the
|
|
247
|
+
project, dependencies, restore, and output paths support that contract.
|
|
248
|
+
- Different frameworks/configurations do not guarantee isolation when custom paths omit their
|
|
249
|
+
discriminators; inspect actual paths.
|
|
250
|
+
|
|
251
|
+
### Build-only references across incompatible frameworks
|
|
252
|
+
|
|
253
|
+
An incompatible assembly cannot become a compiler reference. A build-order-only tool reference
|
|
254
|
+
may need both `ReferenceOutputAssembly="false"` and `SkipGetTargetFrameworkProperties="true"`.
|
|
255
|
+
Bypassing negotiation can also let the caller's global TargetFramework leak into the tool.
|
|
256
|
+
|
|
257
|
+
To build a single-targeted tool as declared:
|
|
258
|
+
|
|
259
|
+
```xml
|
|
260
|
+
<ProjectReference Include="..\Tool\Tool.csproj"
|
|
261
|
+
SkipGetTargetFrameworkProperties="true"
|
|
262
|
+
UndefineProperties="TargetFramework"
|
|
263
|
+
ReferenceOutputAssembly="false" />
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
When an explicit TFM must be selected instead, use `SetTargetFramework` with the intended value.
|
|
267
|
+
Do not simultaneously set and remove the same property. Do not apply this bypass to ordinary
|
|
268
|
+
compatible assembly references, and verify the tool's actual framework/output in the log.
|
|
269
|
+
|
|
270
|
+
## Quick-reference checklist
|
|
271
|
+
|
|
272
|
+
| Source | Check first | Typical concern |
|
|
273
|
+
| --- | --- | --- |
|
|
274
|
+
| AP-02 | Unsafe string conditions | Parsing/correctness |
|
|
275
|
+
| AP-19 | Evaluation side effects | Repeated or unsafe work |
|
|
276
|
+
| AP-21 | Early framework-dependent properties | Silent missing settings |
|
|
277
|
+
| AP-22, AP-23 | Distinct instances sharing outputs | Duplicate builds/races |
|
|
278
|
+
| AP-03 | Machine-specific paths | Portability |
|
|
279
|
+
| AP-06 | Legacy package HintPaths | Dependency migration |
|
|
280
|
+
| AP-07 | Unwanted consumer dependencies/assets | Package contract |
|
|
281
|
+
| AP-11 | Incomplete generation inputs/outputs | Stale or repeated work |
|
|
282
|
+
| AP-13 | Optional versus required imports | Missing dependency behavior |
|
|
283
|
+
| AP-05 | Duplicate source items versus language/order exceptions | Item correctness |
|
|
284
|
+
| AP-04 | Proven redundant defaults versus intentional pins | Maintainability |
|
|
285
|
+
| AP-08, AP-09 | Shared settings or unintended version drift | Consistency |
|
|
286
|
+
| AP-01, AP-16 | Shell operations replaceable by built-ins | Portability/overhead |
|
|
287
|
+
| AP-14, AP-20 | Actual path consumer and platform support | Cross-platform behavior |
|
|
288
|
+
| AP-10 | Mixed target responsibilities | Scheduling/incrementality |
|
|
289
|
+
| AP-12, AP-15 | Assignment timing and intended overrides | Property contracts |
|
|
290
|
+
| AP-17 | Update before Include, not merely a shared ItemGroup | Missing metadata |
|
|
291
|
+
| AP-18 | Real direct dependencies versus redundant edges | Graph/asset contracts |
|
package/package/corpus/skills/msbuild/references/antipatterns/incremental-build-inputs-outputs.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Incremental inputs and outputs on custom targets
|
|
2
|
+
|
|
3
|
+
Expensive artifact-producing targets need complete inputs and real outputs. This is not a rule
|
|
4
|
+
that every validation/orchestration target must have a stamp file.
|
|
5
|
+
|
|
6
|
+
The original catalog's project-file-only example was incomplete when generation depended on
|
|
7
|
+
`$(Version)`: a command-line property can change without touching the project file. A stable
|
|
8
|
+
value-input file can represent that dependency while a separate target registers outputs even
|
|
9
|
+
when generation is skipped:
|
|
10
|
+
|
|
11
|
+
```xml
|
|
12
|
+
<Target Name="WriteBuildInfoInputs">
|
|
13
|
+
<ItemGroup>
|
|
14
|
+
<FileWrites Include="$(IntermediateOutputPath)BuildInfo.inputs" />
|
|
15
|
+
</ItemGroup>
|
|
16
|
+
<MakeDir Directories="$(IntermediateOutputPath)" />
|
|
17
|
+
<WriteLinesToFile File="$(IntermediateOutputPath)BuildInfo.inputs"
|
|
18
|
+
Lines="$(Version)" Overwrite="true" WriteOnlyWhenDifferent="true" />
|
|
19
|
+
</Target>
|
|
20
|
+
|
|
21
|
+
<Target Name="GenerateBuildInfo"
|
|
22
|
+
DependsOnTargets="WriteBuildInfoInputs"
|
|
23
|
+
Inputs="$(MSBuildProjectFullPath);$(MSBuildAllProjects);$(IntermediateOutputPath)BuildInfo.inputs"
|
|
24
|
+
Outputs="$(IntermediateOutputPath)BuildInfo.g.cs">
|
|
25
|
+
<WriteLinesToFile File="$(IntermediateOutputPath)BuildInfo.g.cs"
|
|
26
|
+
Lines="// Generated for $(Version)" Overwrite="true" />
|
|
27
|
+
</Target>
|
|
28
|
+
|
|
29
|
+
<Target Name="RegisterBuildInfo"
|
|
30
|
+
BeforeTargets="CoreCompile"
|
|
31
|
+
DependsOnTargets="GenerateBuildInfo">
|
|
32
|
+
<ItemGroup>
|
|
33
|
+
<Compile Include="$(IntermediateOutputPath)BuildInfo.g.cs" />
|
|
34
|
+
<FileWrites Include="$(IntermediateOutputPath)BuildInfo.g.cs" />
|
|
35
|
+
</ItemGroup>
|
|
36
|
+
</Target>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This illustrates a simple version-dependent producer. Adapt it to the actual generator:
|
|
40
|
+
|
|
41
|
+
- Add its templates, tools, configuration, and source files to the inputs.
|
|
42
|
+
- Serialize every relevant non-file value into a stable fingerprint without losing distinctions.
|
|
43
|
+
Git/clock/network state is not tracked merely by listing the project file.
|
|
44
|
+
- Keep outputs in stable, configuration/framework/runtime-isolated intermediate paths.
|
|
45
|
+
- Ensure generated compile items are registered exactly once on both first and skipped builds.
|
|
46
|
+
Intermediate files are normally excluded from SDK default source globs.
|
|
47
|
+
- Register the state file in its producer before generation can fail, so failed-build cleanup
|
|
48
|
+
records its ownership too. Register generated outputs on successful and skipped generation.
|
|
49
|
+
FileWrites is not a substitute for incremental inputs/outputs or compiler item inclusion.
|
|
50
|
+
- Timestamp checks do not remember a removed wildcard input. Track input-set membership and
|
|
51
|
+
remove obsolete owned outputs when the generator's contract requires it.
|
|
52
|
+
|
|
53
|
+
Verify first build, identical second build, a relevant file/property change, removed inputs,
|
|
54
|
+
deleted output, successful-build Clean, and failed-generation Clean. Do not assume a timestamp-only
|
|
55
|
+
model can distinguish arbitrary same-timestamp mutations. Keep mutation/cleanup experiments confined
|
|
56
|
+
to approved disposable outputs. See [incremental-build](../incremental-build.md) for the full workflow
|
|
57
|
+
and IDE checks.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# PrivateAssets for analyzers and build tools
|
|
2
|
+
|
|
3
|
+
Use `PrivateAssets="all"` when a package is an implementation-only build dependency and must not
|
|
4
|
+
become a dependency of consumers of the produced package.
|
|
5
|
+
|
|
6
|
+
```xml
|
|
7
|
+
<!-- These packages are intended to remain local to this project's build. -->
|
|
8
|
+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" PrivateAssets="all" />
|
|
9
|
+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="all" />
|
|
10
|
+
<PackageReference Include="MinVer" Version="5.0.0" PrivateAssets="all" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Typical candidates from the original catalog include:
|
|
14
|
+
|
|
15
|
+
- Analyzer and code-fix packages.
|
|
16
|
+
- Source generators intended to run only in the producer.
|
|
17
|
+
- SourceLink providers.
|
|
18
|
+
- Versioning tools such as MinVer or Nerdbank.GitVersioning.
|
|
19
|
+
- Build-only compatibility/checking tools.
|
|
20
|
+
|
|
21
|
+
Do not infer a leak merely from a missing literal attribute. Inspect evaluated metadata,
|
|
22
|
+
`IncludeAssets`/`ExcludeAssets`, package contents, generated restore assets, and the packed
|
|
23
|
+
dependency contract. PackageReference's default private-asset categories already restrict some
|
|
24
|
+
asset flow, while `buildTransitive` and other dependencies can have different effects.
|
|
25
|
+
|
|
26
|
+
An analyzer or build extension deliberately distributed to consumers is not a private
|
|
27
|
+
implementation detail. Do not suppress intentional transitive behavior, hide required runtime
|
|
28
|
+
dependencies, or treat `PrivateAssets` as a way to skip building a project.
|
|
29
|
+
Verify the produced package and a representative consumer before declaring the change safe.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Analyzing MSBuild failures with binary logs
|
|
2
|
+
|
|
3
|
+
Based on the original binlog failure analysis skill. Use MSBuild's built-in replay to diagnose
|
|
4
|
+
an existing `.binlog`, including when the original checkout is unavailable.
|
|
5
|
+
|
|
6
|
+
## Before analysis
|
|
7
|
+
|
|
8
|
+
- Reuse a log that records the relevant invocation. If none exists and the build can be reproduced,
|
|
9
|
+
follow [binlog-generation](binlog-generation.md) with the original arguments.
|
|
10
|
+
- A `.binlog` is binary. Do not use a text reader, `strings`, or text search directly on it.
|
|
11
|
+
- Recorded paths identify the original build; they are not permission to search unrelated
|
|
12
|
+
checkouts or proof that source/project files exist locally.
|
|
13
|
+
- Synthesize findings as evidence emerges. Stop once actionable causes and remaining uncertainty
|
|
14
|
+
are clear rather than spending the whole investigation collecting unrelated events.
|
|
15
|
+
|
|
16
|
+
## Replay a binary log
|
|
17
|
+
|
|
18
|
+
Choose unused text-log filenames, substitute the supplied binary-log path, and replay it:
|
|
19
|
+
|
|
20
|
+
```powershell
|
|
21
|
+
dotnet msbuild ".\build.binlog" -noconlog -fl "-flp:logfile=full-01.log;verbosity=diagnostic;PerformanceSummary" -fl1 "-flp1:logfile=errors-01.log;errorsonly" -fl2 "-flp2:logfile=warnings-01.log;warningsonly"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Quote each complete semicolon-delimited logger argument, especially in PowerShell. The command
|
|
25
|
+
reads the recorded build; it does not restore or rebuild its projects. A compatible `MSBuild.exe`
|
|
26
|
+
can replace `dotnet msbuild`; no analysis server or extra package is required.
|
|
27
|
+
|
|
28
|
+
Confirm the command completed and the diagnostic log is nonempty. Errors-only or warnings-only
|
|
29
|
+
logs can legitimately be empty. If the installed MSBuild cannot read the binary-log format,
|
|
30
|
+
report that blocker and the need for compatible tooling instead of pretending analysis succeeded.
|
|
31
|
+
|
|
32
|
+
Replay success is **not** proof that the recorded build succeeded. Replay duration is **not**
|
|
33
|
+
the recorded build's elapsed time. The same replay mechanics serve
|
|
34
|
+
[performance diagnostics](build-perf-diagnostics.md): use recorded events and the Project,
|
|
35
|
+
Target, and Task Performance Summaries, not the time spent converting the log.
|
|
36
|
+
|
|
37
|
+
## Inspect the replayed text
|
|
38
|
+
|
|
39
|
+
Start with errors, then search the diagnostic text around the actual codes, targets, and projects:
|
|
40
|
+
|
|
41
|
+
```powershell
|
|
42
|
+
Get-Content -LiteralPath .\errors-01.log
|
|
43
|
+
Select-String -LiteralPath .\full-01.log -Pattern 'CS0246', 'CoreCompile', 'Build FAILED' -Context 2
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The patterns above are examples, not a filter that should discard other error codes. Inspect the
|
|
47
|
+
recorded evidence needed to explain the failure:
|
|
48
|
+
|
|
49
|
+
- Build errors and warnings, including custom task errors.
|
|
50
|
+
- Project-instance identity, configuration, target framework, and global properties.
|
|
51
|
+
- Property assignments and item/reference metadata visible in the log.
|
|
52
|
+
- Evaluation, import, target, and task execution or skip messages.
|
|
53
|
+
|
|
54
|
+
Text replay cannot manufacture data that was not recorded and does not guarantee extraction of
|
|
55
|
+
embedded project/import source. Read source only when it is available in the current checkout.
|
|
56
|
+
If the responsible definition is absent from both local source and replayed text, state that
|
|
57
|
+
limitation and request the specific missing evidence; do not invent an exact edit location.
|
|
58
|
+
|
|
59
|
+
## Find independent causes
|
|
60
|
+
|
|
61
|
+
1. Associate each error with its project **instance**, target, and task. The same project path
|
|
62
|
+
under different global properties can represent distinct builds.
|
|
63
|
+
2. Follow producer/consumer dependencies. Parallel log order is not causal order: a missing
|
|
64
|
+
referenced assembly may be downstream of a failed producer, while another project has an
|
|
65
|
+
independent failure.
|
|
66
|
+
3. Inspect the actual values seen by the failing task rather than assuming the project body's
|
|
67
|
+
value won. Check conditions, imports, item metadata, and command-line global properties.
|
|
68
|
+
4. Connect each root cause to a minimal repair. A namespace error alone does not prove which
|
|
69
|
+
package should be added; confirm the relevant references and target framework.
|
|
70
|
+
|
|
71
|
+
Use [msbuild-antipatterns](msbuild-antipatterns.md) for a demonstrated authoring defect,
|
|
72
|
+
[extension-points](extension-points.md) for imports/hooks or packed-layout issues, and
|
|
73
|
+
[incremental-build](incremental-build.md) for stale outputs or incorrect skip decisions.
|
|
74
|
+
Do not turn failure diagnosis into an unrequested modernization pass.
|
|
75
|
+
|
|
76
|
+
## Verify and report
|
|
77
|
+
|
|
78
|
+
If source can be changed, rerun the original failing scenario with a new binary log, preserving
|
|
79
|
+
its configuration/framework/properties. Confirm the independent root errors and their cascades
|
|
80
|
+
are resolved, and exercise affected dependents. Check a no-change build when targets/items/outputs
|
|
81
|
+
were changed.
|
|
82
|
+
|
|
83
|
+
For artifact-only analysis, provide proposed changes and explicitly say they were not applied
|
|
84
|
+
or rebuilt. Report the evidence, root causes versus downstream failures, minimal repair, and
|
|
85
|
+
actual verification status. Treat replayed text as sensitive diagnostic data just like its binlog.
|