Skip to content

Commit 1f49eff

Browse files
committed
Merge pull request #717 from Applicita/VsoTask
Converted VSO Task to use PowerShell
2 parents 0efe0b4 + 159b1f4 commit 1f49eff

File tree

2 files changed

+80
-9
lines changed

2 files changed

+80
-9
lines changed

src/GitVersionTfsTask/GitVersion.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
param(
2+
[string]$updateAssemblyInfo,
3+
[string]$updateAssemblyInfoFilename,
4+
[string]$additionalArguments,
5+
[string]$gitVersionPath
6+
)
7+
8+
Write-Verbose "Importing modules"
9+
import-module "Microsoft.TeamFoundation.DistributedTask.Task.Internal"
10+
import-module "Microsoft.TeamFoundation.DistributedTask.Task.Common"
11+
12+
$currentDirectory = Convert-Path .
13+
$sourcesDirectory = $env:Build_SourcesDirectory
14+
15+
Write-Host (Get-LocalizedString -Key "Current Directory: {0}" -ArgumentList $currentDirectory)
16+
Write-Host (Get-LocalizedString -Key "Sources Directory: {0}" -ArgumentList $sourcesDirectory)
17+
18+
Write-Host (Get-LocalizedString -Key "Check/Set GitVersion path")
19+
20+
if(!$gitVersionPath)
21+
{
22+
$gitVersionPath = Join-Path -Path $currentDirectory -ChildPath "GitVersion.exe"
23+
}
24+
25+
if (-not $gitVersionPath)
26+
{
27+
throw (Get-LocalizedString -Key "Unable to locate {0}" -ArgumentList 'gitversion.exe')
28+
}
29+
30+
$argsGitVersion = "$sourcesDirectory" + " /output buildserver /nofetch"
31+
32+
if($updateAssemblyInfo)
33+
{
34+
$argsGitVersion = $argsGitVersion + " /updateassemblyinfo"
35+
36+
if(!$updateAssemblyInfoFilename)
37+
{
38+
$argsGitVersion = $argsGitVersion + " true"
39+
}
40+
else
41+
{
42+
$argsGitVersion = $argsGitVersion + " $updateAssemblyInfoFilename"
43+
}
44+
}
45+
46+
if($additionalArguments)
47+
{
48+
$argsGitVersion = $argsGitVersion + " $additionalArguments"
49+
}
50+
51+
Write-Host (Get-LocalizedString -Key "Invoking GitVersion with {0}" -ArgumentList $argsGitVersion)
52+
53+
Invoke-Tool -Path $GitVersionPath -Arguments "$argsGitVersion"

src/GitVersionTfsTask/task.json

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
"Build",
1111
"Release"
1212
],
13-
"demands": [],
13+
"demands": [ ],
1414
"version": {
15-
"Major": "0",
16-
"Minor": "0",
15+
"Major": "3",
16+
"Minor": "4",
1717
"Patch": "0"
1818
},
1919
"minimumAgentVersion": "1.83.0",
@@ -34,6 +34,15 @@
3434
"required": false,
3535
"helpMarkDown": "Whether to update versions in the AssemblyInfo files"
3636
},
37+
{
38+
"name": "updateAssemblyInfoFilename",
39+
"type": "string",
40+
"label": "Update Assembly File",
41+
"defaultValue": "",
42+
"required": false,
43+
"helpMarkDown": "Update versions in specified file",
44+
"groupName": "additional"
45+
},
3746
{
3847
"name": "additionalArguments",
3948
"type": "string",
@@ -42,13 +51,22 @@
4251
"required": false,
4352
"helpMarkDown": "Additional arguments to send to GitVersion.exe",
4453
"groupName": "additional"
54+
},
55+
{
56+
"name": "gitVersionPath",
57+
"type": "string",
58+
"label": "Path to GitVersion.exe",
59+
"defaultValue": "",
60+
"required": false,
61+
"helpMarkDown": "Optionally supply the path to GitVersion.exe",
62+
"groupName": "additional"
4563
}
4664
],
47-
"execution": {
48-
"Process": {
49-
"target": "$(currentDirectory)\\GitVersion.exe",
50-
"argumentFormat": "\"$(Build.SourcesDirectory)\" /output buildserver /updateAssemblyInfo $(updateAssemblyInfo) /nofetch $(additionalArguments)",
51-
"workingDirectory": "$(currentDirectory)"
65+
"execution": {
66+
"PowerShell": {
67+
"target": "$(currentDirectory)\\GitVersion.ps1",
68+
"argumentFormat": "",
69+
"workingDirectory": ""
5270
}
5371
}
54-
}
72+
}

0 commit comments

Comments
 (0)