-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.ps1
40 lines (28 loc) · 1011 Bytes
/
task.ps1
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
[CmdletBinding()]
param()
Trace-VstsEnteringInvocation $MyInvocation
try {
Import-VstsLocStrings "$PSScriptRoot\task.json"
# Get inputs.
$filePath = Get-VstsInput -Name 'filepath'
$amount = Get-VstsInput -Name 'amount'
$intamount = $amount -as [int]
$yesNo = Get-VstsInput -Name 'yesno' -AsBool
# Run MinApp
$process = Start-Process -FilePath "$PSScriptRoot\MinApp\MinApp.exe" -PassThru -Wait -NoNewWindow -ArgumentList "--filepath",$filePath,"--yesno",$yesNo,"--amount",$intamount
#$process.WaitForExit()
$errorCode = $process.ExitCode
Write-VstsTaskVerbose -Message $errorCode
$failed = $false
# Fail on $LASTEXITCODE
if ($errorCode -ne 0) {
$failed = $true
Write-VstsTaskError -Message (Get-VstsLocString -Key 'Uff')
}
# Fail if any errors.
if ($failed) {
Write-VstsSetResult -Result 'Failed' -Message "Error detected" -DoNotThrow
}
} finally {
Trace-VstsLeavingInvocation $MyInvocation
}