Build SDK
Getting Started
Section titled “Getting Started”This guide walks through the minimal setup required to adopt Purview.BuildSdk in a
repository. Install it once per repo — every project beneath the repo root inherits everything
automatically.
1. Add the SDK to global.json
Section titled “1. Add the SDK to global.json”Add Purview.BuildSdk to the msbuild-sdks section so MSBuild can resolve the SDK:
{ "test": { "runner": "Microsoft.Testing.Platform" }, "msbuild-sdks": { "Purview.BuildSdk": "1.2.0" }}2. Create Directory.Build.props at the repo root
Section titled “2. Create Directory.Build.props at the repo root”<Project> <PropertyGroup> <!-- Required: sets the root namespace prefix for all projects --> <NamespacePrefix>YourCompany</NamespacePrefix> </PropertyGroup>
<Import Sdk="Purview.BuildSdk" Project="Sdk.props" /></Project>NamespacePrefix is mandatory — a build error is raised if it is missing
(ValidateRootNamespacePrefixTarget), unless DisableNamespacePrefixCheck=true.
3. Create Directory.Build.targets at the repo root
Section titled “3. Create Directory.Build.targets at the repo root”<Project> <Import Sdk="Purview.BuildSdk" Project="Sdk.targets" /></Project>4. Copy Directory.Packages.props to the repo root
Section titled “4. Copy Directory.Packages.props to the repo root”Copy templates/Directory.Packages.props
from the repository to your repo root. The templates are not packed into the NuGet package — they are
starting points held in git, so take them from there. Every package names a version. A
PackageVersion is a minimum rather than an exact pin — NuGet resolves it unless something in the
graph requires higher — so floating versions are not needed to stay current, and they would make a
build depend on the day it ran.
Note:
ManagePackageVersionsCentrally=trueis set by the SDK. You must have aDirectory.Packages.propsat your repo root for CPM to work, even if it only contains the packages the SDK adds automatically.
Next steps
Section titled “Next steps”- Read the policy-level guidance in Engineering Principles.
- Understand how projects are detected and named in Project Type Detection and Project Naming Conventions.
- Browse every configurable property in the Configuration Reference.
- Learn how the package version is sourced in Version Detection.
- See how test projects are wired up in Testing Wiring.
- Read how packages are produced in Packaging.