Overview
Use to manage common dependencies across many different projects.
Enabling
- Create a
Directory.Package.props
file at the root of the repository. - Enable central package management:
Directory.Package.props
<Project> <PropertyGroup> <ManagePackageVersionsCentrally> true <ManagePackageVersionsCentrally> </PropertyGroup> </Project>
- For each package, define the package version required for your projects:
<ItemGroup> <PackageVersion Include="PACKAGE.NAME" Version="X.Y.Z" /> </ItemGroup>
- For each project, define a package reference:
<ItemGroup> <PackageReference Include="PACKAGE.NAME" /> </ItemGroup>
Overriding Package Versions
PackageReference
elements can override the version specified inPackageVersion
elements with theVersionOverride
property.- This feature can be disabled in
Directory.Packages.props
by settingCentralPackageVersionOverrideEnabled
tofalse
.
Global Package References
Used to specify that a package will be used by every project in the repository:Directory.Packages.props
<Project>
<ItemGroup>
<GlobalPackageReference Include="PACKAGE.NAME" Version="X.Y.Z" />
</ItemGroup>
</Project>
Considerations
- Only one
Directory.Package.props
file is evaluated for a given project.- The file closest to the project’s directory is evaluated.