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
Copy file name to clipboardExpand all lines: docfx/docs/versionJson.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,7 @@ The content of the version.json file is a JSON serialized object with these prop
34
34
"precision":"revision"// optional. Use when you want a more precise assembly version than the default major.minor.
35
35
},
36
36
"versionHeightOffset":"zOffset", // optional. Use when you need to add/subtract a fixed value from the computed version height.
37
+
"versionHeightOffsetAppliesTo":"x.y-prerelease", // optional. Specifies the version to which versionHeightOffset applies. When the version changes such that version height would reset, and this doesn't match the new version, versionHeightOffset is ignored.
37
38
"semVer1NumericIdentifierPadding":4, // optional. Use when your -prerelease includes numeric identifiers and need semver1 support.
38
39
"gitCommitIdShortFixedLength":10, // optional. Set the commit ID abbreviation length.
39
40
"gitCommitIdShortAutoMinimum":0, // optional. Set to use the short commit ID abbreviation provided by the git repository.
@@ -85,4 +86,27 @@ that assumes linear versioning.
85
86
86
87
When the `cloudBuild.buildNumber.includeCommitId.where` property is set to `fourthVersionComponent`, the first 15 bits of the commit hash is used to create the 4th integer in the version number.
87
88
89
+
## Version Height Offset
90
+
91
+
The `versionHeightOffset` property allows you to add or subtract a fixed value from the git version height. This is typically used as a temporary workaround when migrating from another versioning system or when correcting version numbering discrepancies.
92
+
93
+
The `versionHeightOffsetAppliesTo` property can be used in conjunction with `versionHeightOffset` to ensure that the offset is only applied when the version matches a specific value. When the `version` property changes such that the version height would be reset, and `versionHeightOffsetAppliesTo` does not match the new version, the `versionHeightOffset` will be automatically ignored.
94
+
95
+
This allows version height offsets to implicitly reset as intended when the version changes, without having to manually remove the offset properties from all `version.json` files in the repository.
96
+
97
+
### Example
98
+
99
+
```json
100
+
{
101
+
"version": "1.0-beta",
102
+
"versionHeightOffset": 100,
103
+
"versionHeightOffsetAppliesTo": "1.0-beta"
104
+
}
105
+
```
106
+
107
+
In this example, the offset of 100 will be applied as long as the version remains "1.0-beta". When you update the version to "1.1-alpha" (which would reset the version height), the offset will be automatically ignored because "1.1-alpha" does not match "1.0-beta".
108
+
109
+
> [!NOTE]
110
+
> This feature is particularly useful when a `version.json` file uses `"inherit": true` to get the version from a parent `version.json` file higher in the source tree. In such cases, you can set `versionHeightOffset` and `versionHeightOffsetAppliesTo` in the inheriting file without having to update it when the parent version changes. The offset will automatically stop applying when the inherited version no longer matches `versionHeightOffsetAppliesTo`.
Verify.Operation(adjustedVersionHeight<=MaximumBuildNumberOrRevisionComponent,"Git height is {0}, which is greater than the maximum allowed {0}.",adjustedVersionHeight,MaximumBuildNumberOrRevisionComponent);
Verify.Operation(adjustedVersionHeight<=MaximumBuildNumberOrRevisionComponent,"Git height is {0}, which is greater than the maximum allowed {0}.",adjustedVersionHeight,MaximumBuildNumberOrRevisionComponent);
Copy file name to clipboardExpand all lines: src/NerdBank.GitVersioning/version.schema.json
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,11 @@
68
68
"description": "A number to add to the git height when calculating the version height (which typically appears as the 3rd integer in a computed version). May be negative, but not of greater magnitude than the original git height.",
69
69
"default": 0
70
70
},
71
+
"versionHeightOffsetAppliesTo": {
72
+
"type": "string",
73
+
"description": "The version to which the versionHeightOffset applies. When the version property changes such that the version height would be reset, and this property does not match the new version, the versionHeightOffset will be ignored. This allows the offset to implicitly reset as intended without having to manually remove it from all version.json files.",
"description": "OBSOLETE by v3.0. Use \"versionHeightOffset\" instead. A number to add to the git height when calculating the version height (which typically appears as the 3rd integer in a computed version). May be negative, but not of greater magnitude than the original git height.",
0 commit comments