Skip to content

Commit

Permalink
Fix process invocation for PowerShell handler (#1080)
Browse files Browse the repository at this point in the history
* Replaced the method of process awaiting
  • Loading branch information
DenisNikulin5 authored Dec 10, 2024
1 parent 7898b15 commit 9aa9d4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
8 changes: 2 additions & 6 deletions powershell/VstsTaskSdk/ToolFunctions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,9 @@ function Invoke-Process {
$processOptions.Add("RedirectStandardError", $StdErrPath)
}

# TODO: For some reason, -Wait is not working on agent.
# Agent starts executing the System usage metrics and hangs the step forever.
# We can't use -Wait in this case as it waits for the whole process tree, it can lead to unexprected hangs
$proc = Start-Process @processOptions

# https://stackoverflow.com/a/23797762
$null = $($proc.Handle)
$proc.WaitForExit()
Wait-Process -InputObject $proc

$procExitCode = $proc.ExitCode
Write-Verbose "Exit code: $procExitCode"
Expand Down
8 changes: 4 additions & 4 deletions powershell/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions powershell/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vsts-task-sdk",
"version": "0.21.1",
"version": "0.21.2",
"private": true,
"scripts": {
"build": "node make.js build",
Expand All @@ -16,6 +16,6 @@
"mocha": "5.2.0",
"nodejs-file-downloader": "^4.11.1",
"shelljs": "^0.8.5",
"typescript": "^4.0.2"
"typescript": "4.0.2"
}
}

0 comments on commit 9aa9d4e

Please sign in to comment.