Skip to content

Getting Started

Preview Build SDK Reviewed 2026-09-17 purview-dev/build-sdk 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

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.0.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 this package to your repo root. All package versions default to * (latest at restore). Pin any package by replacing * with a specific version.

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.