--- description: "Use when editing MSBuild files (.csproj, .props, .targets). Covers central package management, artifacts layout, and property inheritance." applyTo: "**/*.{csproj,props,targets}" --- # MSBuild Conventions ## Central Package Management All package versions are declared in `Directory.Packages.props` at the repo root. In `Directory.Packages.props`, ensure the last child element of the root `` tag is ``. `Directory.Packages.template.props` is **READ ONLY**, never edit it. The template provides default `` entries; any entry with the same `Include` declared earlier in `Directory.Packages.props` takes precedence over the template default, because MSBuild uses first-definition-wins semantics and the import appears last. In `.csproj` files: ```xml ``` To add or update a version, edit `Directory.Packages.props`: ```xml ``` If the package does not exist in the template, simply add a new `` entry in `Directory.Packages.props`. No override logic is needed; the entry will be the sole definition. ## Properties Set Centrally (Do Not Override) These are configured in the root `Directory.Build.props` — do **not** set them in individual projects: `LangVersion`, `Nullable`, `ImplicitUsings`. ## InternalsVisibleTo Handled automatically via `` in the root props. Default suffixes are `.Tests` and `Tests`. To add custom visibility: ```xml ``` This is in addition to the automatically generated entries; do not remove or duplicate the default suffix entries.