![]() |
VOOZH | about |
dotnet add package SemanticVersioning --version 3.0.0
NuGet\Install-Package SemanticVersioning -Version 3.0.0
<PackageReference Include="SemanticVersioning" Version="3.0.0" />
<PackageVersion Include="SemanticVersioning" Version="3.0.0" />Directory.Packages.props
<PackageReference Include="SemanticVersioning" />Project file
paket add SemanticVersioning --version 3.0.0
#r "nuget: SemanticVersioning, 3.0.0"
#:package SemanticVersioning@3.0.0
#addin nuget:?package=SemanticVersioning&version=3.0.0Install as a Cake Addin
#tool nuget:?package=SemanticVersioning&version=3.0.0Install as a Cake Tool
This library implements the Semantic Versioning specification and the version range specifications used by npm (node-semver).
SemanticVersioning is available as a NuGet package. To install it, run the following command in the Package Manager Console:
Install-Package SemanticVersioning
Use the SemanticVersioning namespace:
using SemanticVersioning;
Construct a range:
var range = new Range("~1.2.3");
Construct a version:
var version = new Version("1.2.4");
Test whether the version satisfies the range:
bool satisfied = range.IsSatisfied(version);
// satisfied = true
Filter a list of versions to select only those that satisfy a range:
var versions = new [] {
new Version("1.2.1"),
new Version("1.2.3"),
new Version("1.2.8"),
new Version("1.3.2"),
};
IEnumerable<Version> satisfyingVersions = range.Satisfying(versions);
// satisfyingVersions = 1.2.3, 1.2.8
Find the maximum version that satisfies a range:
Version selectedVersion = range.MaxSatisfying(versions);
// selectedVersion = 1.2.8
To get the original input string used when constructing a
version, use Version.ToString().
SemanticVersioning range specifications match the range specifications used by node-semver.
A range specification is constructed by combining multiple
comparator sets with ||, where the range is satisfied if any
of the comparator sets are satisfied.
A comparator set is a combination of comparators, where all comparators must be satisfied for a comparator set to be satisfied.
A comparator is made up of an operator and a version.
An operator is one of: =, >, >=, <, or <=.
For example, the comparator >=1.2.3 specifies versions
greater than or equal to 1.2.3.
An example of a range is >=1.2.3 <1.3.0 || =1.3.2, which
is satisfied by 1.2.3, 1.2.99, and 1.3.2, but not 1.3.0.
Ranges can also be specified using advanced range specification strings, which desugar into comparator sets.
A hyphen range specifies an inclusive range of valid versions, for example
1.2.3 - 1.4.2
is equivalent to >=1.2.3 <=1.4.2.
A partial version string, or a version string with components replaced by an X or a *
matches any version where the specified components match.
For example, 1.2.x is satisfied by 1.2.0 and 1.2.99, but not 1.3.0.
When a minor version is specified, a tilde range only allows changes in the patch version. Otherwise if only the major version is specified, only changes in the minor version are allowed.
Examples:
~1.2.3 is equivalent to >=1.2.3 < 1.3.0~1.2 is equivalent to >=1.2.0 < 1.3.0~1 is equivalent to >=1.0.0 < 2.0.0A caret range allows versions where the most significant non-zero version component does not change.
Examples:
^1.2.3 is equivalent to >=1.2.3 < 2.0.0^0.2.3 is equivalent to >=0.2.3 < 0.3.0^0.0.3 is equivalent to >=0.0.3 < 0.0.4Versions with a pre-release can normally only satisfy ranges that contain a comparator with a pre-release version, and the comparator version's major, minor and patch components must match those of the version being tested.
var range = new Range(">=1.2.3-beta.2");
range.IsSatisfied("1.2.3-beta.3"); // true
range.IsSatisfied("1.2.3-alpha"); // false
range.IsSatisfied("1.2.3"); // true
range.IsSatisfied("1.2.4"); // true
range.IsSatisfied("1.2.4-beta.5"); // false
var range2 = new Range(">=1.2.3");
range2.IsSatisfied("1.2.4-alpha"); // false
To change this behaviour and allow any pre-release version to satisfy a range,
you can set the includePrerelease argument to true:
var range = new Range(">=1.2.3-beta.2");
range.IsSatisfied("1.2.4-beta.5", includePrerelease=true); // true
var range2 = new Range(">=1.2.3");
range2.IsSatisfied("1.2.4-alpha", includePrerelease=true); // true
The Range.Satisfying and Range.MaxSatisfying methods similarly support
an includePrerelease argument to allow any pre-release version.
Version objects implement IEquatable<Version>
and IComparable<Version>, and
can also be compared using ==, >, >=, <, <= and !=.
var a = new Version("1.2.3");
var b = new Version("1.3.0");
a == b; // false
a != b; // true
a > b; // false
a < b; // true
a <= b; // true
The Range and Version constructors will throw
an ArgumentException when an invalid range or version
string is used.
These constructors and all methods that accept versions
as a string have an optional loose parameter, which will
allow some invalid version formats. For example, a pre-release
version without a leading hyphen
will be allowed when loose = true.
var version = new Version("1.2.3alpha"); // Throws ArgumentException
var version = new Version("1.2.3alpha", true); // No exception thrown
The Range class contains separate methods that accept
versions either as strings or as Version objects.
When passing versions as a string to range methods,
invalid version strings will act as if the version does
not satisfy the range, but no exception will be thrown.
Therefore, if you want to know when a version string is invalid,
you should construct Version objects and check for an ArgumentException.
var range = new Range("~1.2.3");
// Returns false:
range.IsSatisfied("banana");
// Version constructor throws ArgumentException:
range.IsSatisfied(new Version("banana"));
For convenience, static methods of the Range class are provided
that accept a range parameter as the first argument and accept versions
as strings, so you don't have to
construct any Range or Version objects if you just want to use one method:
// Returns 1.2.8:
Range.MaxSatisfying("~1.2.3",
new [] {"1.2.1", "1.2.3", "1.2.8", "1.3.2"});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on SemanticVersioning:
| Package | Downloads |
|---|---|
|
Firely.Fhir.Packages
This is Firely's support library for anyone who wants to work with HL7 FHIR packages. |
|
|
FeatureHub.SDK
.Net SDK implementation for FeatureHub.io - Open source Feature flags management, A/B testing and remote configuration platform. |
|
|
Statiq.Core
Statiq is a configurable static content generation framework. |
|
|
Elastic.Stack.ArtifactsApi
Provides a set of classes to resolve the location of Elastic stack products in various stages: released, snapshot and build candidates |
|
|
Relativity.Testing.Framework
The base library for the Relativity.Testing.Framework contains models and handles configuration management. |
Showing the top 19 popular GitHub repositories that depend on SemanticVersioning:
| Repository | Stars |
|---|---|
|
Flow-Launcher/Flow.Launcher
:mag: Quick file search & app launcher for Windows with community-made plugins
|
|
|
BepInEx/BepInEx
Unity / XNA game patcher and plugin framework
|
|
|
STranslate/STranslate
A ready-to-go translation ocr tool developed with WPF/WPF 开发的一款即用即走的翻译、OCR工具
|
|
|
elastic/elasticsearch-net
This strongly-typed, client library enables working with Elasticsearch. It is the official client maintained and supported by Elastic.
|
|
|
antonpup/Aurora
Unified lighting effects across multiple brands and various games.
|
|
|
statiqdev/Statiq
Statiq is a flexible static site generator written in .NET.
|
|
|
geffzhang/NanoFabric
基于Consul + .NET Core + Polly + Ocelot + Exceptionless + IdentityServer等开源项目的微服务开发框架
|
|
|
microsoft/Oryx
Build your repo automatically.
|
|
|
q315523275/FamilyBucket
集合.net core、ocelot、consul、netty、rpc、eventbus、configserver、tracing、sqlsugar、vue-admin、基础管理平台等构建的微服务一条龙应用
|
|
|
microsoft/component-detection
Scans your project to determine what components you use
|
|
|
nats-io/nats.net
Async .NET client for NATS: pub/sub, request/reply, JetStream, KV, Object Store, Services
|
|
|
statiqdev/Statiq.Framework
A flexible and extensible static content generation framework for .NET.
|
|
|
blish-hud/Blish-HUD
A Guild Wars 2 overlay with extreme extensibility through compiled modules.
|
|
|
Lauriethefish/QuestPatcher
Generic il2cpp modding tool for Oculus Quest (1/2/3) apps.
|
|
|
microsoft/OSSGadget
Collection of tools for analyzing open source packages.
|
|
|
Exiled-Team/EXILED
A high-level plugin framework for SCP: Secret Laboratory servers. It offers an event system for developers to hook in order to manipulate or change game code, or implement their own functions.
|
|
|
opensearch-project/opensearch-net
OpenSearch .NET Client
|
|
|
ToniMacaroni/RedLoader
Featureful Sons Of The Forest Modloader
|
|
|
fluffy-mods/ModManager
managing mods should be easy
|
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0 | 1,087,637 | 1/6/2025 |
| 3.0.0-beta2 | 2,172 | 11/1/2023 |
| 3.0.0-beta1 | 267 | 10/17/2023 |
| 2.0.2 | 1,853,107 | 3/14/2022 |
| 2.0.0 | 244,407 | 7/2/2021 |
| 2.0.0-alpha.1 | 423 | 5/13/2021 |
| 1.3.0 | 2,623,990 | 9/26/2020 |
| 1.2.2 | 1,218,989 | 10/12/2019 |
| 1.2.1 | 10,644 | 9/28/2019 |
| 1.2.0 | 3,842,524 | 7/22/2018 |
| 1.1.0 | 32,597 | 4/27/2018 |
| 1.0.0 | 22,966 | 11/7/2017 |
| 0.9.2 | 2,348 | 10/22/2017 |
| 0.8.0 | 465,956 | 3/18/2017 |
| 0.7.6 | 30,866 | 11/7/2016 |
| 0.7.5 | 2,090 | 9/30/2016 |
| 0.7.4 | 2,132 | 9/23/2016 |
| 0.7.3 | 1,824 | 9/23/2016 |
| 0.7.2 | 2,165 | 9/17/2016 |
| 0.6.17 | 2,894 | 4/19/2016 |