Files
templates-dotnet/.github/instructions/msbuild.instructions.md
T

1.1 KiB

description, applyTo
description applyTo
Use when editing MSBuild files (.csproj, .props, .targets). Covers central package management, artifacts layout, and property inheritance. **/*.{csproj,props,targets}

MSBuild Conventions

Central Package Management

All package versions are declared in Directory.Packages.props at the repo root. In .csproj files:

<!-- Correct -->
<PackageReference Include="Newtonsoft.Json" />

<!-- Wrong — never specify Version -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

To add or update a version, edit Directory.Packages.props:

<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />

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 <InternalsVisibleToSuffix> in the root props. Default suffixes are .Tests and Tests. To add custom visibility:

<ItemGroup>
  <InternalsVisibleTo Include="MyProject.IntegrationTests" />
</ItemGroup>