docs: document Directory.Build.props/targets hierarchy in agent instruction files#4984
Conversation
…nstruction files Co-Authored-By: GitHub Copilot <copilot@github.com> Co-authored-by: jamescrosswell <728212+jamescrosswell@users.noreply.github.com>
Clarify MSBuild hierarchical structure and overrides.
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. This PR will not appear in the changelog. 🤖 This preview updates automatically when you update the PR. |
|
|
||
| ### MSBuild hierarchical structure | ||
|
|
||
| MSBuild searches upward from each project file and uses the **nearest** `Directory.Build.props`/`.targets` it finds. Parent files are not automatically included. props/targets files in this repo explicitly `<Import>` parent/root files when appropriate. |
There was a problem hiding this comment.
question: link to Microsoft docs
Shall we have a markdown link to the MSBuild docs?
https://learn.microsoft.com/visualstudio/msbuild/customize-by-directory?view=visualstudio#directorybuildprops-and-directorybuildtargets
Or would links in AGENTS.md just clutter the context?
There was a problem hiding this comment.
The risk is that it follows the link, which will slow it down and add way more context than we really want... so no, I don't think we want to do that. If it keeps stuffing things up re props/targets files even with these instructions, I think we should look at improving these summary/concise instructions rather than linking to docs that are designed to be read by humans.
#skip-changelog
AI coding tools frequently mishandle MSBuild's hierarchical
Directory.Build.props/.targetsresolution — the nearest file wins and parent files are not automatically inherited unless explicitly imported.Changes
AGENTS.md(symlinked asCLAUDE.mdand.github/copilot-instructions.md): expanded the Build System section to explain the "nearest wins" MSBuild lookup rule and lists all subdirectory-level overrides:src/Directory.Build.{props,targets}test/Directory.Build.{props,targets}samples/Directory.Build.{props,targets}benchmarks/Directory.Build.propsintegration-test/Directory.Build.{props,targets}All subdirectory files (except
integration-test/) explicitly<Import>the rootDirectory.Build.props/.targets.Original prompt
Directory.Build.propsandDirectory.Build.targetsto agents.md file #4979✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.