You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| 1.1.*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.2.0-alpha | 1.1.1 | The highest stable version that respects the specified pattern.|
64
+
|\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.3.0-beta | 1.3.0-beta | The highest version including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
65
+
| 1.1.\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.1.2-beta <br> 1.3.0-beta | 1.1.2-beta | The highest version respecting the pattern and including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
66
+
60
67
> [!Note]
61
-
> For information on the behavior of floating versions and pre-release versions, see [Package versioning](package-versioning.md#version-ranges).
68
+
> Floating version resolution does not take into account whether or not a package is listed.
69
+
> Floating version resolution will be resolved locally if the conditions can be satisfied with packages in the Global Package Folder.
Copy file name to clipboardExpand all lines: docs/concepts/Package-Versioning.md
+55-48Lines changed: 55 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,11 +14,15 @@ A specific package is always referred to using its package identifier and an exa
14
14
15
15
When creating a package, you assign a specific version number with an optional pre-release text suffix. When consuming packages, on the other hand, you can specify either an exact version number or a range of acceptable versions.
16
16
17
+
The following document follows the [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) standard, supported by NuGet 4.3.0+ and Visual Studio 2017 version 15.3+.
18
+
Certain [semantics of SemVer v2.0.0](#semantic-versioning-200) are not supported in older clients.
19
+
17
20
In this topic:
18
21
19
22
-[Version basics](#version-basics) including pre-release suffixes.
20
23
-[Version ranges](#version-ranges)
21
24
-[Normalized version numbers](#normalized-version-numbers)
@@ -27,7 +31,7 @@ A specific version number is in the form *Major.Minor.Patch[-Suffix]*, where the
27
31
-*Major*: Breaking changes
28
32
-*Minor*: New features, but backwards compatible
29
33
-*Patch*: Backwards compatible bug fixes only
30
-
-*-Suffix* (optional): a hyphen followed by a string denoting a pre-release version (following the [Semantic Versioning or SemVer 1.0 convention](https://semver.org/spec/v1.0.0.html)).
34
+
-*-Suffix* (optional): a hyphen followed by a string denoting a pre-release version (following the [Semantic Versioning or SemVer](https://semver.org/) convention).
31
35
32
36
**Examples:**
33
37
@@ -51,10 +55,12 @@ That said, package developers generally follow recognized naming conventions:
51
55
-`-beta`: Beta release, typically one that is feature complete for the next planned release, but may contain known bugs.
52
56
-`-rc`: Release candidate, typically a release that's potentially final (stable) unless significant bugs emerge.
53
57
58
+
When ordering versions by precedence, NuGet follows the SemVer standard and chooses a version without a suffix first, then applies precedence to pre-release versions in reverse alphabetical order and treats dot notation numbers with numerical order.
59
+
54
60
> [!Note]
55
-
> NuGet 4.3.0+ supports [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html), which supports pre-release numbers with dot notation, as in *1.0.1-build.23*. Dot notation is not supported with NuGet versions before 4.3.0. You can use a form like *1.0.1-build23*. It is recommended to use NuGet 4.3.0+, because nuget.org and newer NuGet clients will not treat "1.0.1-build23" as greater than "1.0.1-build3".
61
+
> Prerelease numbers with dot notation, as in *1.0.1-build.23*, are considered are part of the [SemVer 2.0.0](https://semver.org/spec/v2.0.0.html) standard, and as such are [only supported with NuGet 4.3.0+](#semantic-versioning-200).
56
62
57
-
When resolving package references and multiple package versions differ only by suffix, NuGet chooses a version without a suffix first, then applies precedence to pre-release versions in reverse alphabetical order and treats dot notation numbers with numerical order. For example, the following versions would be chosen in the exact order shown:
63
+
### [SemVer 2.0 sorting](#tab/semver20sort)
58
64
59
65
```
60
66
1.0.1
@@ -68,37 +74,28 @@ When resolving package references and multiple package versions differ only by s
68
74
1.0.1-aaa
69
75
```
70
76
71
-
Note that, 1.0.1-alpha10 is sorted strictly in reverse alphabetical order, whereas 1.0.1-rc.10 is greater precedence than 1.0.1-rc.2.
72
-
73
-
## Semantic Versioning 2.0.0
74
-
75
-
With NuGet 4.3.0+ and Visual Studio 2017 version 15.3+, NuGet supports [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html).
77
+
Note that 1.0.1-alpha10 is sorted strictly in reverse alphabetical order, whereas 1.0.1-rc.10 is greater precedence than 1.0.1-rc.2.
76
78
77
-
Certain semantics of SemVer v2.0.0 are not supported in older clients. NuGet considers a package version to be SemVer v2.0.0 specific if either of the following statements is true:
79
+
### [SemVer 1.0 sorting](#tab/semver10sort)
78
80
79
-
- The pre-release label is dot-separated, for example, *1.0.0-alpha.1*
80
-
- The version has build-metadata, for example, *1.0.0+githash*
81
-
82
-
For nuget.org, a package is defined as a SemVer v2.0.0 package if either of the following statements is true:
83
-
84
-
- The package's own version is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, as defined above.
85
-
- Any of the package's dependency version ranges has a minimum or maximum version that is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, defined above; for example, *[1.0.0-alpha.1, )*.
86
-
87
-
If you upload a SemVer v2.0.0-specific package to nuget.org, the package is invisible to older clients and available to only the following NuGet clients:
88
-
89
-
- NuGet 4.3.0+
90
-
- Visual Studio 2017 version 15.3+
91
-
- Visual Studio 2015 with [NuGet VSIX v3.6.0](https://dist.nuget.org/visualstudio-2015-vsix/latest/NuGet.Tools.vsix)
92
-
- dotnet
93
-
- dotnetcore.exe (.NET SDK 2.0.0+)
81
+
```
82
+
1.0.1
83
+
1.0.1-zzz
84
+
1.0.1-open
85
+
1.0.1-beta05
86
+
1.0.1-beta02
87
+
1.0.1-beta
88
+
1.0.1-alpha2
89
+
1.0.1-alpha10
90
+
1.0.1-aaa
91
+
```
94
92
95
-
Third-party clients:
93
+
Note that versions such as `1.0.1-rc.10` and `1.0.1-rc.2` are not parsable by older versions of the client, and such packages with those versions won't be available for download with those clients.
96
94
97
-
- JetBrains Rider
98
-
- Paket version 5.0+
95
+
If you use numerical suffixes with pre-release tags that might use double-digit numbers (or more), use leading zeroes as in beta01 and beta05 to ensure that they sort correctly when the numbers get larger.
96
+
This recommendation only applies this schema.
99
97
100
-
<!-- For compatibility with previous dependency-versions page -->
101
-
<aname="version-ranges"></a>
98
+
---
102
99
103
100
## Version ranges
104
101
@@ -117,11 +114,6 @@ When referring to package dependencies, NuGet supports using interval notation f
117
114
|[1.0,2.0) | 1.0 ≤ x < 2.0 | Mixed inclusive minimum and exclusive maximum version |
118
115
| (1.0) | invalid | invalid |
119
116
120
-
When using the PackageReference format, NuGet also supports using a floating notation, \*, for Major, Minor, Patch, and pre-release suffix parts of the number. Floating versions are not supported with the `packages.config` format. When a floating version is specified, the rule is to resolve to the highest existent version that matches the version description. Examples of floating versions and the resolutions are below.
121
-
122
-
> [!Note]
123
-
> Version ranges in PackageReference include pre-release versions. By design, floating versions do not resolve prerelease versions unless opted into. For the status of the related feature request, see [issue 6434](https://github.com/NuGet/Home/issues/6434#issuecomment-358782297).
124
-
125
117
### Examples
126
118
127
119
Always specify a version or version range for package dependencies in project files, `packages.config` files, and `.nuspec` files. Without a version or version range, NuGet 2.8.x and earlier chooses the latest available package version when resolving a dependency, whereas NuGet 3.x and later chooses the lowest package version. Specifying a version or version range avoids this uncertainty.
@@ -158,19 +150,6 @@ Always specify a version or version range for package dependencies in project fi
| 1.1.*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.2.0-alpha | 1.1.1 | The highest stable version that respects the specified pattern.|
167
-
|\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.3.0-beta | 1.3.0-beta | The highest version including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
168
-
| 1.1.\*-\*| 1.1.0 <br> 1.1.1 <br> 1.1.2-alpha <br> 1.1.2-beta <br> 1.3.0-beta | 1.1.2-beta | The highest version respecting the pattern and including the not stable versions. | Available in Visual Studio version 16.6, NuGet version 5.6, .NET Core SDK version 3.1.300 |
169
-
170
-
> [!Note]
171
-
> Floating version resolution does not take into account whether or not a package is listed.
172
-
> Floating version resolution will be resolved locally if the conditions can be satisfied with packages in the Global Package Folder.
173
-
174
153
**References in `packages.config`:**
175
154
176
155
In `packages.config`, every dependency is listed with an exact `version` attribute that's used when restoring packages. The `allowedVersions` attribute is used only during update operations to constrain the versions to which the package might be updated.
@@ -229,7 +208,7 @@ The `version` attribute in a `<dependency>` element describes the range versions
229
208
## Normalized version numbers
230
209
231
210
> [!Note]
232
-
> This is a breaking change for NuGet 3.4 and later.
211
+
> This is a breaking change for NuGet 3.4+.
233
212
234
213
When obtaining packages from a repository during install, reinstall, or restore operations, NuGet 3.4+ treats version numbers as follows:
235
214
@@ -249,6 +228,34 @@ When obtaining packages from a repository during install, reinstall, or restore
249
228
250
229
However, NuGet package repositories must treat these values in the same way as NuGet to prevent package version duplication. Thus a repository that contains version *1.0* of a package should not also host version *1.0.0* as a separate and different package.
251
230
231
+
## Semantic Versioning 2.0.0
232
+
233
+
Certain semantics of SemVer v2.0.0 are not supported in older clients.
234
+
NuGet considers a package version to be SemVer v2.0.0 specific if either of the following statements is true:
235
+
236
+
- The pre-release label is dot-separated, for example, *1.0.0-alpha.1*
237
+
- The version has build-metadata, for example, *1.0.0+githash*
238
+
239
+
For nuget.org, a package is defined as a SemVer v2.0.0 package if either of the following statements is true:
240
+
241
+
- The package's own version is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, as defined above.
242
+
- Any of the package's dependency version ranges has a minimum or maximum version that is SemVer v2.0.0 compliant but not SemVer v1.0.0 compliant, defined above; for example, *[1.0.0-alpha.1, )*.
243
+
244
+
If you upload a SemVer v2.0.0-specific package to nuget.org, the package is invisible to older clients and available to only the following NuGet clients:
245
+
246
+
- NuGet 4.3.0+
247
+
- Visual Studio 2017 version 15.3+
248
+
- Visual Studio 2015 with [NuGet VSIX v3.6.0](https://dist.nuget.org/visualstudio-2015-vsix/latest/NuGet.Tools.vsix)
249
+
- .NET SDK 2.0.0+
250
+
251
+
Third-party clients:
252
+
253
+
- JetBrains Rider
254
+
- Paket version 5.0+
255
+
256
+
<!-- For compatibility with previous dependency-versions page -->
257
+
<aname="version-ranges"></a>
258
+
252
259
## Where NuGetVersion diverges from Semantic Versioning
253
260
254
261
If you want to programatically use NuGet package versions, it is strongly recommended to use [the package NuGet.Versioning](https://www.nuget.org/packages/NuGet.Versioning). The static method `NuGetVersion.Parse(string)` can be used to parse the version strings, and `VersionComparer` can be used to sort `NuGetVersion` instances.
Copy file name to clipboardExpand all lines: docs/create-packages/Prerelease-Packages.md
+1-35Lines changed: 1 addition & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,38 +52,4 @@ By default, NuGet does not include pre-release versions when working with packag
52
52
## Semantic versioning
53
53
54
54
The [Semantic Versioning or SemVer convention](https://semver.org/spec/v1.0.0.html) describes how to utilize strings in version numbers to convey the meaning of the underlying code.
55
-
56
-
In this convention, each version has three parts, `Major.Minor.Patch`, with the following meaning:
57
-
58
-
- `Major`: Breaking changes
59
-
- `Minor`: New features, but backwards compatible
60
-
- `Patch`: Backwards compatible bug fixes only
61
-
62
-
Pre-release versions are then denoted by appending a hyphen and a string after the patch number. Technically speaking, you can use *any* string after the hyphen and NuGet will treat the package as pre-release. NuGet then displays the full version number in the applicable UI, leaving consumers to interpret the meaning for themselves.
63
-
64
-
With this in mind, it's generally good to follow recognized naming conventions such as the following:
65
-
66
-
- `-alpha`: Alpha release, typically used for work-in-progress and experimentation
67
-
- `-beta`: Beta release, typically one that is feature complete for the next planned release, but may contain known bugs.
68
-
- `-rc`: Release candidate, typically a release that's potentially final (stable) unless significant bugs emerge.
69
-
70
-
> [!Note]
71
-
> NuGet 4.3.0+ supports [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html), which supports pre-release numbers with dot notation, as in `1.0.1-build.23`. Dot notation is not supported with NuGet versions before 4.3.0. In earlier versions of NuGet, you could use a form like `1.0.1-build23` but this was always considered a pre-release version.
72
-
73
-
Whatever suffixes you use, however, NuGet will give them precedence in reverse alphabetical order:
74
-
75
-
```
76
-
1.0.1
77
-
1.0.1-zzz
78
-
1.0.1-rc
79
-
1.0.1-open
80
-
1.0.1-beta.12
81
-
1.0.1-beta.5
82
-
1.0.1-beta
83
-
1.0.1-alpha.2
84
-
1.0.1-alpha
85
-
```
86
-
87
-
As shown, the version without any suffix will always take precedence over pre-release versions.
88
-
89
-
Leading 0s are not needed with semver2, but they are with the old version schema. If you use numerical suffixes with pre-release tags that might use double-digit numbers (or more), use leading zeroes as in beta.01 and beta.05 to ensure that they sort correctly when the numbers get larger. This recommendation only applies to the old version schema.
55
+
[Learn more](../concepts/Package-Versioning.md) about the package versioning basics.
0 commit comments