I am unable to find the reason for the below script to fail in 1ES hosted pool:
Script:
$env:SSH_ROOT="C:\OpenSSH-Win64"
$pinfo=New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName="c:\\Program Files\\dotnet\\dotnet.exe"
#$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$dllDir="$(System.ArtifactsDirectory)".replace("\","\\")
$isMultipleDevice="$(isAndroidParallel)"
If($isMultipleDevice -eq "True"){
$pinfo.Arguments = "$dllDir\\EmulatorAccess.dll """"startall"""" --api 29 --api 29"
}
else{
$pinfo.Arguments = "$dllDir\\EmulatorAccess.dll """"start"""" """"28"""""
}
$p=New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
Write-Host "Setting path"
Set-Location -Path C:\Agent\_work\_temp
pwd
ls
Write-Host "-----------Displaying values in P----------"
Write-Host $p
Write-Host $p.value
$p.Start() | Out-Null
$p.WaitForExit(50000)
$stdout=$p.StandardOutput.ReadToEnd()
#$stderr=$p.StandardError.ReadLine()
Write-Host "stdout: $stdout"
If($isMultipleDevice -eq "True"){
$stdOutArr = $stdout -split " "
If($stdOutArr.Count -eq 5) {
$arr=$stdout -split "`r`n"
$stdoutOne=$arr[0]
$stdoutTwo=$arr[1]
} else {
$stdoutOne = $stdOutArr[0].trim() + " " + $stdOutArr[1].trim() + " " + $stdOutArr[2].trim()
$stdoutTwo = $stdOutArr[3].trim() + " " + $stdOutArr[4].trim() + " " + $stdOutArr[5].trim()
}
Write-Host "stdout1: "
$stdoutOne
Write-Host "stdout2: "
$stdoutTwo
$stdout=$stdoutOne+ "_" + $stdoutTwo
}
Write-Host "--------------------------------------------------------------"
Write-Host "##vso[task.setvariable variable=StopCode;]$stdout"
Error:
Exception calling “Start” with “0” argument(s): “The system cannot find the file specified” At D:\a_work_temp\de966ca7-f235-45de-844a-8ed9803020d4.ps1:31 char:1 $p.Start() | Out-Null
- CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
Note: The file “D:\a_work_temp\de966ca7-f235-45de-844a-8ed9803020d4.ps1” exist in the agent.