SemanticVersions 1.0.0

dotnet add package SemanticVersions --version 1.0.0
                    
NuGet\Install-Package SemanticVersions -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SemanticVersions" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SemanticVersions" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="SemanticVersions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SemanticVersions --version 1.0.0
                    
#r "nuget: SemanticVersions, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SemanticVersions@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SemanticVersions&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=SemanticVersions&version=1.0.0
                    
Install as a Cake Tool

SemanticVersions for .NET

The C# implementation of Semantic Versions: parse, validate, compare and range-match version numbers, with builds that participate in precedence.

It is a port of the JavaScript reference implementation (semantic-versions on npm) and behaves identically: both pass the same conformance suite, and they agree on every version, range and resolution in the benchmark corpus. For .NET 8+, no dependencies, AOT-compatible.

Install

dotnet add package SemanticVersions

Usage

using SemanticVersions;

var v = SemanticVersion.Parse("1.2.3-beta.4+build.7");
// v.Major == 1, v.Prerelease == "beta.4", v.Build == "build.7"

// Builds participate in precedence: a build ranks above its plain release.
bool above = SemanticVersion.Parse("1.0.0") < SemanticVersion.Parse("1.0.0+build.1"); // true

Versions.Satisfies("1.4.0", "^1.2.3");             // true
Versions.Satisfies("1.0.0-rc.1", "^1.0.0-rc");     // true: pre-release channel
Versions.Satisfies("1.0.0-beta", "^1.0.0-rc");     // false: a different channel
Versions.Satisfies("1.4.2+win.x64", "^1.0.0+win"); // true: build channel
Versions.ValidRange("~>1.2");                      // ">=1.2.0 <1.3.0-0"

// Contexts scope a version or range to an identity.
var react = SemanticRange.Parse("npm:react@^18");
react.Test(SemanticVersion.Parse("npm:react@18.2.0"));   // true
react.Test(SemanticVersion.Parse("nuget:react@18.2.0")); // false

Versions.MaxSatisfying(["1.0.0", "1.9.0", "2.0.0"], "^1"); // "1.9.0"

Parse throws SemanticVersionException (a FormatException); TryParse returns false instead. Versions.Sort is stable.

How this differs from Semver and SemanticVersioning

  • Builds participate in precedence (1.0.0 < 1.0.0+build), and a build on a comparator is a channel filter.
  • Pre-releases are range-driven: a pre-release on a comparator is a prefix channel scoped to its tuple; X.Y.Z-* and *-* opt in explicitly.
  • Contexts: npm:react@18.2.0, npm:@babel/core@^7.
  • No coercion: v1.2.3 and 1.2 are errors.

Performance and conformance

Compared with Semver and SemanticVersioning on real versions and dependency ranges from the npm registry. Method and raw results: benchmarks/. All implementations: semver.xyz/libraries.

Speed

Operation semantic-versions@1.0.0 Semver@3.0.0 SemanticVersioning@3.0.0 semantic-versions vs Semver
Parse a version 31.9 ns 311 ns 521 ns 9.7× faster
Sort versions 89.4 ns 135 ns 695 ns 1.5× faster
Parse a range 335 ns 646 ns 19.1 µs 1.9× faster
range.Test(version) 6.0 ns 7.8 ns 68.6 ns 1.3× faster
Resolve a range 1.21 µs 1.64 µs 27.1 µs 1.4× faster

<sub>Median time per operation (lower is better) on 5,398 published versions and 1,996 dependency ranges from the npm registry. .NET 10.0.15 · Intel(R) Xeon(R) Processor @ 2.30GHz · linux x64 · 2026-11-19. Semver: Compared by precedence (ComparePrecedence), which ignores builds as SemVer 2.0.0 specifies.</sub>

Conformance

Semantic Versions feature semantic-versions Semver SemanticVersioning
Version grammar <br><sub>Valid and invalid versions per the BNF</sub> ✓ 81/81 ◐ 80/81 ◐ 57/81
No coercion <br><sub>Rejects v1.2.3, =1.2.3, 1.2.3pre, …</sub> ✓ 11/11 ✓ 11/11 ◐ 7/11
Precedence <br><sub>Major, minor, patch and pre-release ordering</sub> ✓ 32/32 ✓ 32/32 ✓ 32/32
Build precedence <br><sub>A build ranks above its release: 1.0.0 < 1.0.0+b</sub> ✓ 10/10 ◐ 1/10 ◐ 1/10
Ranges <br><sub>Comparators, \|\|, x-ranges, ~, ^, hyphen ranges</sub> ✓ 199/199 ✓ 172/172 ✓ 172/172
Approximate ranges <br><sub>The pessimistic operator ~></sub> ✓ 17/17 ✓ 13/13 ◐ 7/13
Pre-release channels <br><sub>^1.0.0-rc admits rc.*, never beta</sub> ✓ 44/44 ◐ 33/44 ◐ 33/44
Pre-release wildcards <br><sub>X.Y.Z-* and *-* opt in explicitly</sub> ✓ 14/14 ◐ 2/13 ◐ 2/13
Build channels <br><sub>^1.0.0+win admits +win.* builds only</sub> ✓ 24/24 ◐ 12/22 ◐ 12/22
Contexts <br><sub>npm:react@18.2.0, npm:react@^18</sub> ✓ 15/15 ◐ 3/15 ◐ 3/15
All cases 447/447 359/413 326/413

<sub>Cases from the shared conformance suite in conformance/, drawn from the specification. ✓ all pass · ◐ some pass · ✗ none pass.</sub>

Develop

dotnet run --project tests/SemanticVersions.Conformance   # conformance suite
dotnet run -c Release --project bench                     # benchmarks
dotnet pack src/SemanticVersions -c Release               # the NuGet package

License

Apache-2.0. The specification is at semver.xyz.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 0 11/19/2026