docs/roslyn-analyzers/acquisition-strategy.md
This document describes how consumers should acquire the Microsoft.CodeAnalysis. (Roslyn) analyzer packages* over time, and why the acquisition model changes across major versions.
dotnet/roslyn-analyzer, especially when builds must run on older compilers/hosts.PackageReference-based acquisition to SDK-provided analyzers enabled by configuration properties.Directory.Build.props) to ease future migration.For package versions less than or equal to 3.11.0:
dotnet/roslyn-analyzer repository.Implication for consumers: these packages were broadly compatible with older toolchains, making them a good choice when analyzer execution had to work across older environments.
The dotnet/roslyn-analyzer repository was merged into dotnet/roslyn. As part of that consolidation:
For the new 5.0 packages:
Implication for consumers: using 5.0 analyzers assumes your build uses a sufficiently new compiler/SDK. If your build environment is older, these analyzers are not a supported choice.
Today, acquisition is typically done via NuGet PackageReference, for example:
.csproj) or centrally in Directory.Build.props.This model works but has downsides:
The long-term goal is to ship these analyzer packages in the .NET SDK. Currently Roslyn ships their CodeStyle analyzers in the SDK. Consumers opt-in to using them via the EnforceCodeStyleInBuild property.
When analyzers ship in the SDK:
PackageReference, you enable analyzers by setting MSBuild properties in your .csproj or Directory.Build.props.Conceptually, consumers will move from:
to:
configured in one of:
.csproj)Directory.Build.props (recommended for repository-wide policy)(Exact property names and final UX may evolve as the SDK integration is finalized.)