Back to results for “Assemblies & NuGet”
.NET › Assemblies & NuGet

How does semantic versioning apply to NuGet packages, and what do version range operators like [1.0,2.0) mean?

Advanced

Answer

NuGet packages follow SemVer (MAJOR.MINOR.PATCH), and PackageReference version strings support range syntax: a plain '1.0.3' means 'this version or higher' (minimum version, NuGet's default interpretation), while explicit interval notation like [1.0,2.0) means 'greater than or equal to 1.0, less than 2.0' (square brackets inclusive, parentheses exclusive), letting you constrain acceptable upgrade ranges precisely.
<!-- Minimum version (most common) -->
<PackageReference Include="Serilog" Version="3.1.0" />

<!-- Exact version only -->
<PackageReference Include="Serilog" Version="[3.1.0]" />

<!-- Range: >= 3.0, < 4.0 -->
<PackageReference Include="Serilog" Version="[3.0,4.0)" />
Real-world example A library author pins a range like [3.0,4.0) for a dependency known to have breaking changes at major version boundaries, protecting consuming applications from an unexpected breaking upgrade during a routine restore.

Common follow-ups: Why does NuGet default to treating a plain version number as a minimum rather than exact?;How do floating versions like 3.1.* work?