Skip to content
Purview Dev logo

Build SDK

Stable Build SDK Reviewed 2026-10-28 purview-dev/build-sdk Star on GitHub 1 central-package-management code-style csharp developer-experience developer-tooling devex dotnet msbuild msbuild-sdk nuget project-templates roslyn roslyn-analyzers roslyn-generators tunit xunit llms.txt

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.

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=true is set by the SDK. You must have a Directory.Packages.props at your repo root for CPM to work, even if it only contains the packages the SDK adds automatically.