Skip to content

Commit 53ae501

Browse files
author
Pascal Berger
committed
Fix versioning of TFS task during build.
Fixes #941
1 parent a3c2adf commit 53ae501

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/GitVersionExe/GitVersionExe.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@
188188
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\task.json" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
189189
<Copy SourceFiles="$(SolutionDir)GitVersionTfsTask\GitVersion.ps1" DestinationFolder="$(BuildDir)GitVersionTfsTaskBuild\GitVersionTask" />
190190
<ReplaceFileText InputFilename="$(BuildDir)GitVersionTfsTaskBuild\manifest.json" OutputFilename="$(BuildDir)GitVersionTfsTaskBuild\manifest.json" MatchExpression="\$version\$" ReplacementText="$(GitVersion_SemVer)" Condition="'$(GitVersion_SemVer)' != ''" />
191-
<Exec Command="powershell -ExecutionPolicy RemoteSigned -NoProfile &quot;$(SolutionDir)GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 $(BuildDir)GitVersionTfsTaskBuild\GitVersionTask\task.json $(GitVersion_Major) $(GitVersion_Minor) $(GitVersion_Patch)&quot;" WorkingDirectory="$(BuildDir)" Condition="'$(GitVersion_SemVer)' != ''" />
191+
<Exec Command="powershell -ExecutionPolicy RemoteSigned -NoProfile &quot;$(SolutionDir)GitVersionTfsTask\Update-GitVersionTfsTaskVersion.ps1 $(BuildDir)GitVersionTfsTaskBuild\GitVersionTask\task.json $(GitVersion_MajorMinorPatch)&quot;" WorkingDirectory="$(BuildDir)" Condition="'$(GitVersion_MajorMinorPatch)' != ''" />
192192
<Exec Command="powershell -ExecutionPolicy RemoteSigned -NoProfile &quot;$(SolutionDir)GitVersionTfsTask\Create-Vsix.ps1 $(BuildDir)GitVersionTfsTaskBuild&quot;" Condition="'$(GitVersion_SemVer)' != ''" />
193193

194194
<!-- Gem -->

src/GitVersionTfsTask/Update-GitVersionTfsTaskVersion.ps1

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,26 @@
11
param (
22
[string] $filePath,
3-
[string] $major,
4-
[string] $minor,
5-
[string] $patch
3+
[string] $version
64
)
75

86
if ([string]::IsNullOrWhiteSpace($filePath)) {
97
throw "File path needs to be provided."
108
}
119

12-
if ([string]::IsNullOrWhiteSpace($major)) {
13-
throw "Major version number needs to be provided."
10+
if ([string]::IsNullOrWhiteSpace($version)) {
11+
throw "Version number needs to be provided."
1412
}
1513

16-
if ([string]::IsNullOrWhiteSpace($minor)) {
17-
throw "Minor version number needs to be provided."
18-
}
19-
20-
if ([string]::IsNullOrWhiteSpace($patch)) {
21-
throw "Patch level needs to be provided."
22-
}
14+
Write-Host "Set version in '$filePath' to $version"
2315

24-
Write-Host "Set version in '$filePath' to $major.$minor.$patch"
16+
$ver = [Version]$version
2517

2618
# Get the task.json as a powershell object
2719
$task = Get-Content -Raw -Path $filePath | ConvertFrom-Json
2820

29-
$task.version.Major = $major
30-
$task.version.Minor = $minor
31-
$task.version.Patch = $patch
21+
$task.version.Major = $ver.Major
22+
$task.version.Minor = $ver.Minor
23+
$task.version.Patch = $ver.Build
3224

3325
# get this as a string again
3426

0 commit comments

Comments
 (0)