@@ -22,7 +22,7 @@ You can now use standard .NET numeric format strings with version components:
22
22
23
23
``` yaml
24
24
# GitVersion.yml
25
- template : " {Major}.{Minor}.{Patch:F2}-{PreReleaseLabel}"
25
+ assembly-informational-format : " {Major}.{Minor}.{Patch:F2}-{PreReleaseLabel}"
26
26
` ` `
27
27
28
28
**Supported Numeric Formats:**
@@ -39,7 +39,7 @@ template: "{Major}.{Minor}.{Patch:F2}-{PreReleaseLabel}"
39
39
When working with date-related properties like `CommitDate` :
40
40
41
41
` ` ` yaml
42
- template : "Build-{SemVer}-{CommitDate:yyyy-MM-dd}"
42
+ assembly-informational-format : "Build-{SemVer}-{CommitDate:yyyy-MM-dd}"
43
43
` ` `
44
44
45
45
**Common Date Format Specifiers:**
@@ -71,15 +71,15 @@ branches:
71
71
feature:
72
72
label: "{BranchName:c}" # Converts to PascalCase
73
73
74
- template : "{Major}.{Minor}.{Patch}-{PreReleaseLabel:l}.{CommitsSinceVersionSource:0000}"
74
+ assembly-informational-format : "{Major}.{Minor}.{Patch}-{PreReleaseLabel:l}.{CommitsSinceVersionSource:0000}"
75
75
` ` `
76
76
77
77
**Template Usage:**
78
78
79
79
` ` ` yaml
80
80
# Using format strings in templates
81
81
assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
82
- template : "{SemVer}-{BranchName:l}"
82
+ assembly-informational-format : "{SemVer}-{BranchName:l}"
83
83
` ` `
84
84
85
85
# # Examples
@@ -107,21 +107,21 @@ branches:
107
107
# ## Date and Time Formatting
108
108
109
109
` ` ` yaml
110
- template : "{SemVer}-build-{CommitDate:yyyy-MM-dd}"
110
+ assembly-informational-format : "{SemVer}-build-{CommitDate:yyyy-MM-dd}"
111
111
# Result: "1.2.3-build-2021-01-01"
112
112
` ` `
113
113
114
114
# ## Numeric Formatting
115
115
116
116
` ` ` yaml
117
117
# Currency format (uses InvariantCulture)
118
- template : "Cost-{Major:C}" # Result: "Cost-¤1.00"
118
+ assembly-informational-format : "Cost-{Major:C}" # Result: "Cost-¤1.00"
119
119
120
120
# Percentage format
121
- template : "Progress-{Minor:P}" # Result: "Progress-200.00 %"
121
+ assembly-informational-format : "Progress-{Minor:P}" # Result: "Progress-200.00 %"
122
122
123
123
# Thousands separator
124
- template : "Build-{CommitsSinceVersionSource:N0}" # Result: "Build-1,234"
124
+ assembly-informational-format : "Build-{CommitsSinceVersionSource:N0}" # Result: "Build-1,234"
125
125
` ` `
126
126
127
127
# # Configuration Integration
@@ -137,28 +137,11 @@ assembly-versioning-format: "{Major}.{Minor}.{Patch}.{env:BUILD_NUMBER}"
137
137
assembly-file-versioning-format: "{MajorMinorPatch}.{CommitsSinceVersionSource}"
138
138
` ` `
139
139
140
- # ## Template-Based Configuration
141
-
142
- ` ` ` yaml
143
- # Global template for consistent formatting across all variables
144
- template: "{SemVer}-{BranchName:l}-{ShortSha}"
145
-
146
- branches:
147
- main:
148
- label: ""
149
- feature:
150
- label: "{BranchName:c}.{CommitsSinceVersionSource}"
151
- increment: Minor
152
- release:
153
- label: "rc-{CommitsSinceVersionSource:000}"
154
- increment: None
155
- ` ` `
156
-
157
140
# ## Environment Variable Integration
158
141
159
142
` ` ` yaml
160
143
# Using environment variables with fallbacks
161
- template : "{Major}.{Minor}.{Patch}-{env:RELEASE_STAGE ?? 'dev'}"
144
+ assembly-informational-format : "{Major}.{Minor}.{Patch}-{env:RELEASE_STAGE ?? 'dev'}"
162
145
assembly-informational-format: "{SemVer}+{env:BUILD_ID ?? 'local'}"
163
146
` ` `
164
147
@@ -196,57 +179,3 @@ The formatting system uses `CultureInfo.InvariantCulture` by default through the
196
179
` ` `
197
180
198
181
This ensures that version strings generated by GitVersion are consistent across different build environments, developer machines, and CI/CD systems.
199
-
200
- # # Verified Examples
201
-
202
- The following examples are verified by actual unit tests in the GitVersion codebase :
203
-
204
- # ## Zero-Padded Numeric Formatting
205
-
206
- ` ` ` yaml
207
- assembly-informational-format: "{Major}.{Minor}.{Patch}-{CommitsSinceVersionSource:0000}"
208
- ` ` `
209
-
210
- **Test**: `VariableProviderTests.Format_Allows_CSharp_FormatStrings()`
211
- **Input**: `CommitsSinceVersionSource = 42`
212
- **Output**: `"1.2.3-0042"`
213
-
214
- # ## String Case Transformations
215
-
216
- ` ` ` csharp
217
- // From StringFormatterTests.cs
218
- [TestCase("hello world", "c", "HelloWorld")] // PascalCase
219
- [TestCase("hello", "u", "HELLO")] // Uppercase
220
- [TestCase("HELLO", "l", "hello")] // Lowercase
221
- [TestCase("hello world", "t", "Hello World")] // Title Case
222
- [TestCase("hELLO", "s", "Hello")] // Sentence Case
223
- ` ` `
224
-
225
- # ## Numeric Format Specifiers
226
-
227
- ` ` ` csharp
228
- // From NumericFormatterTests.cs
229
- [TestCase("1234.5678", "n", "1,234.57")] // Number format
230
- [TestCase("1234.5678", "f2", "1234.57")] // Fixed-point format
231
- [TestCase("1234.5678", "f0", "1235")] // No decimals
232
- ` ` `
233
-
234
- # ## Date Formatting
235
-
236
- ` ` ` csharp
237
- // From DateFormatterTests.cs
238
- [TestCase("2021-01-01", "yyyy-MM-dd", "2021-01-01")]
239
- [TestCase("2021-01-01T12:00:00Z", "yyyy-MM-ddTHH:mm:ssZ", "2021-01-01T12:00:00Z")]
240
- ` ` `
241
-
242
- # ## Currency and Percentage (InvariantCulture)
243
-
244
- ` ` ` csharp
245
- // From FormattableFormatterTests.cs
246
- [TestCase(123.456, "C", "¤123.46")] // Generic currency symbol
247
- [TestCase(123.456, "P", "12,345.60 %")] // Percentage format
248
- [TestCase(1234567890, "N0", "1,234,567,890")] // Thousands separators
249
- ` ` `
250
-
251
- [reference-configuration] : /docs/reference/configuration
252
- [variables] : /docs/reference/variables
0 commit comments