-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDTFindVersion.psm1
783 lines (643 loc) · 24.7 KB
/
DTFindVersion.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
<#
Daniele's Tools Find Version
Copyright (C) 2022 Daniznf
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
https://github.com/daniznf/DTFindVersion
#>
function Find-VersionInLine
{
param (
[Parameter(Mandatory)]
[string]
$Line
)
$Version = $null
$Found = $Line -match "(?<Start>\D*)(?<Major>\d+)\.(?<Minor>\d+)\.?(?<Build>\d+)?\.?(?<Revision>\d+)?(?<End>\D*)"
if ($Found)
{
if ($Matches["Major"] -and $Matches["Minor"])
{
if ($Matches["Build"])
{
if ($Matches["Revision"])
{
$Version = [Version]::new($Matches["Major"], $Matches["Minor"], $Matches["Build"], $Matches["Revision"])
}
else
{
$Version = [Version]::new($Matches["Major"], $Matches["Minor"], $Matches["Build"])
}
}
else
{
$Version = [Version]::new($Matches["Major"], $Matches["Minor"])
}
}
}
if ($Version)
{
return $Matches["Start"], $Version, $Matches["End"]
}
else
{
return $null
}
<#
.SYNOPSIS
Finds version in Line.
.DESCRIPTION
Parses input line of text and extracts the version part.
Version contained in Line must follow Major.Minor[.Build[.Revision]] pattern, e.g.:
1.2.3.4 or 1.2.3 or 1.2
.PARAMETER Line
Line to scan.
.OUTPUTS
An array composed of:
- [0] = first part of the line, before version
- [1] = a version object
- [2] = last part of the line, after version
#>
}
function Update-Version {
param (
[Parameter(Mandatory)]
[Version]
$Version,
[Parameter(Mandatory, ParameterSetName="Increment")]
[ValidateSet("Major", "Minor", "Build", "Revision")]
[string]
$Increment,
[Parameter(Mandatory, ParameterSetName="Generate")]
[ValidateSet("BuildAndRevision", "Build", "Revision")]
[string]
$Generate,
[Parameter(ParameterSetName="Generate")]
[int]
$DayOffset,
[Parameter(Mandatory, ParameterSetName="Generate")]
[datetime]
$Now
)
$NewMajor = $Version.Major
$NewMinor = $Version.Minor
$NewBuild = $Version.Build
$NewRevision = $Version.Revision
$HasBuild = $Version.Build -gt -1
$HasRevision = $Version.Revision -gt -1
if ($Increment)
{
if ($Increment -eq "Major") { $NewMajor++ }
if ($Increment -eq "Minor") { $NewMinor++ }
if ($Increment -eq "Build" -and $HasBuild) { $NewBuild++ }
if ($Increment -eq "Revision" -and $HasRevision) { $NewRevision++ }
}
elseif ($Generate)
{
# Max 365
$DayPart = ($Now).DayOfYear + $DayOffset
if ($DayPart -lt 0) { $DayPart = 0 }
if ($Generate -eq "BuildAndRevision")
{
# Max 8640
$SecondPart = ($Now).Hour * 60 * 60 + ($Now).Minute * 60 + ($Now).Second
$SecondPart = [System.Math]::Round($SecondPart / 10)
$NewBuild = $DayPart
$NewRevision = $SecondPart
}
else
{
# Max 1440
$TotalMinutes = ($Now).Hour * 60 + ($Now).Minute
# Up to 45 days, 12 hours and 15 minutes produces a build number lower than 65536.
$MinutePart = $DayPart * 1440 + $TotalMinutes
if ($Generate -eq "Build")
{
$NewBuild = $MinutePart
if ($HasRevision) { $NewRevision = $Version.Revision }
}
else # ($Generate -eq "Revision")
{
if ($HasBuild) { $NewBuild = $Version.Build }
else { $NewBuild = 0 }
$NewRevision = $MinutePart
}
}
}
# Version always has Major and Minor.
if ($HasBuild)
{
if ($HasRevision) { $NewVersion = [version]::new($NewMajor, $NewMinor, $NewBuild, $NewRevision) }
else { $NewVersion = [version]::new($NewMajor, $NewMinor, $NewBuild) }
}
else { $NewVersion = [version]::new($NewMajor, $NewMinor) }
return $NewVersion
<#
.SYNOPSIS
Updates version.
.DESCRIPTION
.PARAMETER Version
Version object to update.
.PARAMETER Increment
Value to increment.
.PARAMETER Generate
Generates a new version number for Build or Revision, or both.
If -Generate is Build, the whole number will be written in Build part.
If -Generate is Revision, the whole number will be written in Revision part.
If -Generate is BuildAndRevision, the first part of the generated number
will be written in Build and the second part in Revision.
.PARAMETER DayOffset,
A positive or negative number of days to add to the "day" part of the Generate algorithm.
.PARAMETER Now
A Datetime used to generate number, retrieved before calling this function.
.OUTPUTS
A new Version with updated values.
.NOTES
Both -Generate Build and -Generate Revision produce a shorter number than
-Generate BuildAndRevision, to help maintaining it lower than 65535.
If a bigger number is produced, -DayOffset can be used to reduce it.
#>
}
function Select-Language {
param (
[Parameter(Mandatory)]
[string]
$FilePath
)
$Language = $null
if ($FilePath.Contains("."))
{
$FileExtension = $FilePath.Substring($FilePath.LastIndexOf(".") +1)
switch ($FileExtension)
{
"cs" { $Language = "cs"; break }
"xml" { $Language = "xml"; break }
"csproj" { $Language = "xml"; break }
"js" { $Language = "js"; break }
"ps1" { $Language = "ps"; break }
"psm1" { $Language = "ps"; break }
"psd1" { $Language = "ps"; break }
"vb" { $Language = "vb"; break }
"bat" { $Language = "bat"; break }
Default { $Language = $null }
}
}
return $Language
<#
.SYNOPSIS
Guesses Language of file, based on file extension.
.OUTPUTS
A string corresponding to language.
#>
}
function Find-VersionInFile
{
param (
[Parameter(Mandatory, ParameterSetName="Find")]
[Parameter(Mandatory, ParameterSetName="Increment")]
[Parameter(Mandatory, ParameterSetName="Generate")]
[string]
$FilePath,
[Parameter(ParameterSetName="Find")]
[Parameter(ParameterSetName="Increment")]
[Parameter(ParameterSetName="Generate")]
[string[]]
$VersionKeywords,
[Parameter(ParameterSetName="Find")]
[Parameter(ParameterSetName="Increment")]
[Parameter(ParameterSetName="Generate")]
[ValidateSet("cs", "xml", "js", "ps", "vb", "bat")]
[string]
$Language,
[Parameter(Mandatory, ParameterSetName="Increment")]
[ValidateSet("Major", "Minor", "Build", "Revision")]
[string]
$Increment,
[Parameter(Mandatory, ParameterSetName="Generate")]
[ValidateSet("BuildAndRevision", "Build", "Revision")]
[string]
$Generate,
[Parameter(ParameterSetName="Generate")]
[int]
$DayOffset,
[Parameter(ParameterSetName="Increment")]
[Parameter(ParameterSetName="Generate")]
[Alias("DryRun")]
[switch]
$WhatIf
)
$WhatIfParam = @{}
if ($WhatIf) { $WhatIfParam.Add("WhatIf", $true) }
# Get a datetime now so all updates will have the same version number.
if ($Generate) { $Now = Get-Date }
$Versions = [System.Collections.ArrayList]::new()
if ( -not (Test-Path $FilePath)) { throw [System.IO.FileNotFoundException]::new("Could not find $FilePath") }
# Language is needed to understand file read below.
if (-not $Language)
{
$SelectedLanguage = Select-Language -FilePath $FilePath
if ($SelectedLanguage)
{
$Language = $SelectedLanguage
Write-Verbose "File language has been automatically set to $Language."
}
else { Write-Verbose "Could not select file language!" }
}
# Use Language to understand code comments.
$Comment, $CommentStart, $CommentEnd, $CutOffset = $null
switch ($Language)
{
{ $_ -in "cs", "js" }
{
$Comment = "//"
$CommentStart = "/*"
$CommentEnd = "*/"
break
}
"xml"
{
$CommentStart = "<!--"
$CommentEnd = "-->"
break
}
"ps"
{
$Comment = "#"
$CommentStart = "<#"
$CommentEnd = "#>"
break
}
"vb"
{
$Comment = "'"
break
}
"bat"
{
$Comment = "REM"
break
}
Default { }
}
# $CutOffset is needed when $CommentEnd is longer than 1 char, like "-->" .
if ($CommentEnd) { $CutOffset = $CommentEnd.Length }
# Stop when access to file is denied
$FileContent = Get-Content $FilePath -ErrorAction Stop
# Make a backup if file is going to be updated.
if ($Increment -or $Generate)
{
$FilePathBak = $FilePath + ".bak"
Write-Verbose "Creating backup in $FilePathBak"
$null = Move-Item -Path $FilePath -Destination $FilePathBak -Force -ErrorAction Stop @WhatIfParam
$null = Copy-Item -Path $FilePathBak -Destination $FilePath -ErrorAction Ignore @WhatIfParam
}
# If file is 1 line long, $FileContent will be string, but an Array is needed.
if ($FileContent -is [string]) { $FileContent = @($FileContent) }
for ($i = 0; $i -lt $FileContent.Length; $i++)
{
$Start, $Version, $End = $null
$IgnoredBefore, $IgnoredMiddle, $IgnoredAfter = $null
$Cut, $CutStart, $CutEnd = -1
$OrLine = $FileContent[$i]
$Line = $OrLine
$VersionFound = $false
if ($VersionKeywords -is [System.String[]])
{
for ($j = 0; $j -lt $VersionKeywords.Length; $j++)
{
if ($OrLine.Contains($VersionKeywords[$j]))
{
$VersionFound = $true
break
}
}
}
else
{
if ($OrLine.Contains($VersionKeywords)) { $VersionFound = $true }
}
if (($null -eq $VersionKeywords) -or ($VersionFound))
{
# Remove comments from $Line, and then parse it to find a version.
# Multi-line comments.
if ($CommentStart -and $CommentEnd)
{
# Some languages do not have $CommentStart and $CommentEnd.
$CutStart = $OrLine.IndexOf($CommentStart)
$CutEnd = $OrLine.IndexOf($CommentEnd)
if ($CutStart -gt -1)
{
if ($CutEnd -gt -1)
{
if ($CutEnd -gt $CutStart)
{
if ($OrLine.Trim().IndexOf($CommentStart) -eq 0)
{
# <# comment #> Version
$Line = $OrLine.Substring($CutEnd + $CutOffset)
$IgnoredBefore = $OrLine.Substring(0, $CutEnd + $CutOffset)
}
elseif ($OrLine.Trim().IndexOf($CommentEnd) -eq ($OrLine.Trim().Length - $CutOffset))
{
# Version <# comment #>
$Line = $OrLine.Substring(0, $CutStart)
$IgnoredAfter = $OrLine.Substring($CutStart)
}
else
{
# Version <# comment #> Version
$Line = $OrLine.Substring(0, $CutStart)
$IgnoredMiddle = $OrLine.Substring($CutStart, ($CutEnd + $CutOffset - $CutStart))
$Line += $OrLine.Substring($CutEnd + $CutOffset)
}
}
else
{
# comment#> Version <# comment
$Line = $OrLine.Substring($CutEnd + $CutOffset, ($CutStart - $CutEnd - $CutOffset))
$IgnoredBefore = $OrLine.Substring(0, $CutEnd + $CutOffset)
$IgnoredAfter = $OrLine.Substring($CutStart)
}
}
else
{
# Version <# comment
$Line = $OrLine.Substring(0, $CutStart)
$IgnoredAfter = $OrLine.Substring($CutStart)
}
}
else
{
if ($CutEnd -gt -1)
{
# comment #> Version
$Line = $OrLine.Substring($CutEnd + $CutOffset)
$IgnoredBefore = $OrLine.Substring(0, $CutEnd + $CutOffset)
}
}
}
# Single Line Comment.
if ($Comment)
{
$Cut = $OrLine.IndexOf($Comment)
if (($Cut -gt -1) -and ($CutStart -eq -1) -and ($CutEnd -eq -1))
{
# Version # comment
$Line = $OrLine.Substring(0, $Cut)
$IgnoredAfter = $OrLine.Substring($Cut)
}
}
# $Line is now clean. But it could be empty if all line was a comment with one of $VersionKeywords within.
if ($Line)
{
$Start, $Version, $End = Find-VersionInLine -Line $Line
if ($Version)
{
if ($Increment -or $Generate)
{
$UpdateParams = @{ "Version" = $Version }
if ($Increment) { $UpdateParams.Add("Increment", $Increment) }
if ($Generate)
{
$UpdateParams.Add("Generate", $Generate)
$UpdateParams.Add("Now", $Now)
if ($DayOffset) { $UpdateParams.Add("DayOffset", $DayOffset) }
}
$UpdatedVersion = Update-Version @UpdateParams
}
# Restore $Line to original state, with comments, etc.
$Line = $OrLine
if ($UpdatedVersion)
{
$Line = $Line.Replace($Version, $UpdatedVersion)
Write-Verbose ("New version " + $UpdatedVersion.ToString() + " in line ""$Line""")
$null = $Versions.Add(@{"Version" = $UpdatedVersion; "Line" = $Line})
}
else
{
Write-Verbose ("Found version " + $Version.ToString() + " in line ""$Line""")
$null = $Versions.Add(@{"Version" = $Version; "Line" = $Line})
}
}
else
{
# $Line contains one of $VersionKeywords but does not contain a version.
$Line = $OrLine
}
}
else
{
# Line contains one of $VersionKeywords but is a comment.
$Line = $OrLine
}
if ($IgnoredBefore -or $IgnoredMiddle -or $IgnoredAfter)
{
$IgnoredLine = $IgnoredBefore
if ($IgnoredBefore -and ($IgnoredMiddle -or $IgnoredAfter)) {$IgnoredLine += "; "}
$IgnoredLine += $IgnoredMiddle
if (($IgnoredBefore -or $IgnoredMiddle) -and $IgnoredAfter) {$IgnoredLine += "; "}
$IgnoredLine += $IgnoredAfter
Write-Verbose "Ignoring $IgnoredLine"
}
}
$FileContent[$i] = $Line
}
if ($Increment -or $Generate)
{
Set-Content -Path $FilePath -Value $FileContent @WhatIfParam
}
return $Versions
<#
.SYNOPSIS
Finds or updates version in text file.
.DESCRIPTION
Parses input text file and extracts all Versions found in lines that contain one of $VersionKeywords.
If -Increment or -Generate is used, version will be updated in file accordingly.
.PARAMETER FilePath
Complete path of file to scan.
.PARAMETER VersionKeywords,
String(s) to search,
E.g: -VersionKeywords "Version"
E.g. -VersionKeywords "AssemblyVersion","FileVersion"
.PARAMETER Language
Language of the file, used to properly handle comments.
.PARAMETER Increment
Value to increment.
.PARAMETER Generate
Generates a new version number for Build or Revision, or both.
If -Generate is Build, the whole number will be written in Build part.
If -Generate is Revision, the whole number will be written in Revision part.
If -Generate is BuildAndRevision, the first part of the generated number
will be written in Build and the second part in Revision.
.PARAMETER DayOffset,
A positive or negative number to add to the "day" part of the Generate algorithm.
.OUTPUTS
Array of hashtables, one for each line containing a version, composed of:
- [Version] = a version object found in line
- [Line] = the complete line
.NOTES
If Increment or Generate is used, file will be updated, not piped to output.
#>
}
function Find-Version
{
param (
[Parameter(Mandatory, ParameterSetName="FindLine")]
[Parameter(Mandatory, ParameterSetName="IncrementLine")]
[Parameter(Mandatory, ParameterSetName="GenerateLine")]
[string]
$Line,
[Parameter(Mandatory, ParameterSetName="FindFile")]
[Parameter(Mandatory, ParameterSetName="IncrementFile")]
[Parameter(Mandatory, ParameterSetName="GenerateFile")]
[string]
$FilePath,
[Parameter(ParameterSetName="FindFile")]
[Parameter(ParameterSetName="IncrementFile")]
[Parameter(ParameterSetName="GenerateFile")]
[string[]]
$VersionKeywords,
[Parameter(ParameterSetName="FindFile")]
[Parameter(ParameterSetName="IncrementFile")]
[Parameter(ParameterSetName="GenerateFile")]
[ValidateSet("cs", "xml", "js", "ps", "vb", "bat")]
[string]
$Language,
[Parameter(Mandatory, ParameterSetName="IncrementLine")]
[Parameter(Mandatory, ParameterSetName="IncrementFile")]
[ValidateSet("Major", "Minor", "Build", "Revision")]
[string]
$Increment,
[Parameter(Mandatory, ParameterSetName="GenerateLine")]
[Parameter(Mandatory, ParameterSetName="GenerateFile")]
[ValidateSet("BuildAndRevision", "Build", "Revision")]
[string]
$Generate,
[Parameter(ParameterSetName="GenerateLine")]
[Parameter(ParameterSetName="GenerateFile")]
[int]
$DayOffset,
[Parameter(ParameterSetName="IncrementFile")]
[Parameter(ParameterSetName="GenerateFile")]
[Alias("DryRun")]
[switch]
$WhatIf
)
$UpdateArgs = @{}
$FileArgs = @{}
if ($Increment) { $UpdateArgs.Add("Increment", $Increment) }
if ($Generate)
{
$UpdateArgs.Add("Generate", $Generate)
if ($DayOffset) { $UpdateArgs.Add("DayOffset", $DayOffset) }
}
if ($FilePath)
{
$FileArgs.Add("FilePath", $FilePath)
if ($Language) { $FileArgs.Add("Language", $Language) }
if ($VersionKeywords) { $FileArgs.Add("VersionKeywords", $VersionKeywords) }
}
if ($Line)
{
$Start, $Version, $End = Find-VersionInLine -Line $Line
if ($Increment -or $Generate)
{
$UpdatedVersion = Update-Version -Version $Version @UpdateArgs
return $UpdatedVersion, $Line.Replace($Version, $UpdatedVersion)
}
else
{
return $Version, $Line
}
}
if ($FilePath)
{
if ($Increment -or $Generate)
{
if ($WhatIf) { $FileArgs.Add("WhatIf", $WhatIf) }
$Versions = Find-VersionInFile @FileArgs @UpdateArgs
return ( $Versions | ForEach-Object { write-host ("New version {0} in line {1}" -f $_.Version, $_.Line.Trim()) } )
}
else
{
return Find-VersionInFile @FileArgs
}
}
<#
.SYNOPSIS
Finds and updates version in text line or text file.
.DESCRIPTION
If -Line is passed:
Parses input line of text and extracts the version part.
Version contained in Line must follow Major.Minor[.Build[.Revision]] pattern, e.g.:
1.2.3.4 or 1.2.3 or 1.2.
If -FilePath is passed:
Parses input text file and extracts all Versions found in lines that contain $VersionKeywords.
If -Increment or -Generate is used, version will be updated accordingly.
.PARAMETER Line
Line to scan.
.PARAMETER FilePath
Complete path of file to scan.
.PARAMETER VersionKeywords
Word(s) to search:
E.g: -VersionKeywords "Version"
E.g. -VersionKeywords "AssemblyVersion","FileVersion"
.PARAMETER Language
Language of the file, used to properly handle comments.
.PARAMETER Increment
Value to increment.
.PARAMETER Generate
Generates a new version number for Build or Revision, or both.
If -Generate is Build, the whole number will be written in Build part.
If -Generate is Revision, the whole number will be written in Revision part.
If -Generate is BuildAndRevision, the first part of the generated number
will be written in Build and the second part in Revision.
.PARAMETER DayOffset
A positive or negative number to add to the "day" part of the Generate algorithm.
.PARAMETER WhatIf
Do not actually write file, only display what would happen.
.NOTES
Both -Generate Build and -Generate Revision produce a shorter number than
-Generate BuildAndRevision, to help maintaining it lower than 65535.
If a bigger number is produced, -DayOffset can be used to reduce it.
.EXAMPLE
Find-Version -Line "Version 1.2.3"
Will return a Version object and the original line:
Major Minor Build Revision
----- ----- ----- --------
1 2 3 -1
Version 1.2.3
.EXAMPLE
Find-Version -Line "Version 1.2.3" -Increment Build
Will return an updated Version object with Build incremented by 1, and the modified line:
Major Minor Build Revision
----- ----- ----- --------
1 2 4 -1
Version 1.2.4
.EXAMPLE
Find-Version -FilePath .\Tests\Net60-Test.csproj -VersionKeywords AssemblyVersion
Will return all Version objects extracted from lines that contain "AssemblyVersion", and all the corresponding lines:
Name Value
---- -----
Version 1.2.3
Line <AssemblyVersion>1.2.3</AssemblyVersion>
.EXAMPLE
Find-Version -FilePath .\Tests\Net60-Test.csproj -VersionKeywords AssemblyVersion -Increment Build
Will update the file (making a backup before) updating all lines that contain "AssemblyVersion" incrementing Build part by 1.
All updates will also be written to output:
New AssemblyVersion: 1.2.4
.Example
Find-Version -FilePath .\Tests\Net60-Test.csproj -VersionKeywords AssemblyVersion -Generate BuildAndRevision
Will update the file (making a backup before) updating all lines that contain "AssemblyVersion" generating new Build and Revision numbers.
All updates will also be written to output:
New AssemblyVersion: 1.2.278.3769
#>
}