Central Package Management (CPM) is explicitly scoped to a repository: a Directory.Packages.props file is discovered by MSBuild only by walking up the directory tree from a given project, and only one such file is automatically evaluated per project by default.
For a microservices architecture where each service lives in its own repository, CPM should therefore be used per repository, not across repositories:
- Each repo gets its own
Directory.Packages.props (usually at the repo root) with ManagePackageVersionsCentrally set to true and the relevant <PackageVersion /> items for that service.
- Projects in that repo use
<PackageReference Include="PackageX" /> without Version, letting the repo-local Directory.Packages.props control versions.
- If a single repo contains multiple services or solutions, additional
Directory.Packages.props files can be placed in subfolders to refine versions for subsets of projects, optionally importing the parent file when needed.
This aligns well with microservices principles:
- CPM is a build-time, per-repo concern and does not introduce runtime coupling between services.
- Each service remains independently versioned and deployable; dependency versions are coordinated only within that service’s repo.
Trying to share a single Directory.Packages.props across multiple repositories is not supported by the CPM discovery rules and would require custom, out-of-band mechanisms (for example, copying or generating the file into each repo). That kind of cross-repo coupling is closer to monorepo-style coordination and can work, but it is a process decision rather than a CPM feature.
If strong, global consistency of package versions across services is required, a monorepo (single repository) is the model that naturally benefits most from CPM, as described for single repositories: it simplifies dependency management and cross-cutting changes. In a multi-repo microservices setup, CPM should be treated as a per-repo optimization, not a cross-repo mechanism.
References: