WinAppDriver Azure Pipelines Task stop command is flaky

Created on 17 Jul 2019  路  15Comments  路  Source: microsoft/WinAppDriver

We have recently integrated WinAppDriver into our builds at Accessibility Insights for Windows. We've been seeing periodic errors in relation to stopping WinAppDriver in our build pipeline. The YAML we use is as follows:

  - task: WinAppDriver.winappdriver-pipelines-task.winappdriver-pipelines-task.Windows Application Driver@0
    displayName: 'Stop - WinAppDriver'
    inputs:
      OperationType: Stop

This usually works as expected, but sometimes fails with:

  | ##[error]The process cannot access the file 'D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\winappdriverlog.txt' because it is being used by another process. |  

Full log output at end of issue.

Do you know if there is something we may be doing that causes this error? Or is it an issue with the build task itself?

聽 | ##[debug]Evaluating condition for step: 'Stop - WinAppDriver' | 聽
聽 | ##[debug]Evaluating: SucceededNode() | 聽
聽 | ##[debug]Evaluating SucceededNode: | 聽
聽 | ##[debug]=> True | 聽
聽 | ##[debug]Result: True | 聽
聽 | Starting: Stop - WinAppDriver | 聽
聽 | ============================================================================== | 聽
聽 | Task         : WinAppDriver | 聽
聽 | Description  : Use this extention to integrate Windows Application Driver (WinAppDriver) into your Azure Pipeline. | 聽
聽 | Version      : 0.0.1 | 聽
聽 | Author       : Microsoft | 聽
聽 | Help         : Checkout the WinAppDriver GitHub Repo to learn more - https://github.com/Microsoft/WinAppDriver | 聽
聽 | ============================================================================== | 聽
聽 | ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4 | 聽
聽 | ##[debug]Entering D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\WADPowershell.ps1. | 聽
聽 | ##[debug]Loading resource strings from: D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\task.json | 聽
聽 | ##[debug]Loaded 0 strings. | 聽
聽 | ##[debug]SYSTEM_CULTURE: 'en-US' | 聽
聽 | ##[debug]INPUT_OPERATIONTYPE: 'Stop' | 聽
聽 | ##[debug]INPUT_WADARGUMENTS (empty) | 聽
聽 | ##[debug]INPUT_AGENTRESOLUTION: 'Default' | 聽
聽 | Successfully closed WinAppDriver on Agent | 聽
聽 | 聽 | 聽
聽 | Printing WinAppDriver Console logs: | 聽
聽 | 聽 | 聽
聽 | ##[debug]Caught exception from task script. | 聽
聽 | ##[debug]Error record: | 聽
聽 | ##[debug]Out-File : The process cannot access the file 'D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\winappdriverlog.txt' because it is being used by another process. | 聽
聽 | ##[debug]At D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\WADPowershell.ps1:41 char:2 | 聽
聽 | ##[debug]+     Out-File -Encoding Unicode -append winappdriverlog.txt | 聽
聽 | ##[debug]+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 聽
聽 | ##[debug]    + CategoryInfo          : OpenError: (:) [Out-File], IOException | 聽
聽 | ##[debug]    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand | 聽
聽 | ##[debug] | 聽
聽 | ##[debug]Script stack trace: | 聽
聽 | ##[debug]at <ScriptBlock>, D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\WADPowershell.ps1: line 41 | 聽
聽 | ##[debug]at <ScriptBlock>, <No file>: line 1 | 聽
聽 | ##[debug]at <ScriptBlock>, <No file>: line 22 | 聽
聽 | ##[debug]at <ScriptBlock>, <No file>: line 18 | 聽
聽 | ##[debug]at <ScriptBlock>, <No file>: line 1 | 聽
聽 | ##[debug]Exception: | 聽
聽 | ##[debug]System.IO.IOException: The process cannot access the file 'D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\winappdriverlog.txt' because it is being used by another process. | 聽
聽 | ##[debug]   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) | 聽
聽 | ##[debug]   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) | 聽
聽 | ##[debug]   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) | 聽
聽 | ##[debug]   at System.Management.Automation.PathUtils.MasterStreamOpen(PSCmdlet cmdlet, String filePath, Encoding resolvedEncoding, Boolean defaultEncoding, Boolean Append, Boolean Force, Boolean NoClobber, FileStream& fileStream, StreamWriter& streamWriter, FileInfo& readOnlyFileInfo, Boolean isLiteralPath) | 聽
聽 | ##[error]The process cannot access the file 'D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\winappdriverlog.txt' because it is being used by another process. | 聽
聽 | ##[debug]Processed: ##vso[task.logissue type=error]The process cannot access the file 'D:\a\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.1\winappdriverlog.txt' because it is being used by another process. | 聽
聽 | ##[debug]Processed: ##vso[task.complete result=Failed] | 聽
聽 | Finishing: Stop - WinAppDriver
DevOps - Azure Pipelines

Most helpful comment

Closing this issue is a little premature IMO. The fix for this issue introduced a new bug that we're also seeing.
Also on a self hosted agent.
My extension settings are saying 0.0.1.7 is the latest version.

All 15 comments

Thanks for reporting this @jalkire, I'm investigating into it.

@jalkire - this appears to be an I/O error that happens on edge cases, notably with the use of private agents.

I _just_ pushed out a new build now which hopefully mitigates this issue - though since I haven't been able to repro the issue myself, I am unable to validate.

Could you try the following,

1) Confirm that the WinAppDriver task version is 0.0.2.
1) Check to see if the issue still persists on this latest version - you don't need to make any changes to your YAML.
1) If the issue does still persist, could you try adjusting the "Start - WinAppDriver" YAML to include the following launch argument:

steps:
- task: WinAppDriver.winappdriver-pipelines-task.winappdriver-pipelines-task.Windows Application Driver@0
  displayName: 'Start - WinAppDriver'
  inputs:
    WADArguments: 4723
    AgentResolution: 1080p

Let me know if any of these helps resolve it. If possible, please share more details about your agent's environment (type, OS, build version, etc.) as that would very helpful in repro'ing.

Thanks!

@hassanuz It seems that with this latest update I am now getting the following error when executing the WinAppDriver Stop command

##[error]Cannot find path 'C:\winappdriverlog.txt' because it does not exist.

This Pipeline had been running successfully until this morning, and it coincides with the update of the latest version.

##[debug]Evaluating condition for step: 'Stop - WinAppDriver' | 聽
-- | --
聽 | ##[debug]Evaluating: always() | 聽
聽 | ##[debug]Evaluating always: | 聽
聽 | ##[debug]=> True | 聽
聽 | ##[debug]Result: True | 聽
聽 | Starting: Stop - WinAppDriver | 聽
聽 | ============================================================================== | 聽
聽 | Task         : WinAppDriver | 聽
聽 | Description  : Use this extention to integrate Windows Application Driver (WinAppDriver) into your Azure Pipeline. | 聽
聽 | Version      : 0.0.2 | 聽
聽 | Author       : Microsoft | 聽
聽 | Help         : Checkout the WinAppDriver GitHub Repo to learn more - https://github.com/Microsoft/WinAppDriver | 聽
聽 | ============================================================================== | 聽
聽 | ##[debug]VstsTaskSdk 0.11.0 commit 7ff27a3e0bdd6f7b06690ae5f5b63cb84d0f23f4 | 聽
聽 | ##[debug]Entering C:\Agent\_work\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.2\WADPowershell.ps1. | 聽
聽 | ##[debug]Loading resource strings from: C:\Agent\_work\_tasks\Windows Application Driver_f7c56e2a-d1f1-4cff-b5d3-a32c9516c6e0\0.0.2\task.json | 聽
聽 | ##[debug]Loaded 0 strings. | 聽
聽 | ##[debug]SYSTEM_CULTURE: 'en-US' | 聽
聽 | ##[debug]INPUT_OPERATIONTYPE: 'Stop' | 聽
聽 | ##[debug]INPUT_WADARGUMENTS (empty) | 聽
聽 | ##[debug]INPUT_AGENTRESOLUTION: 'Default' | 聽
聽 | Attempting to close WinAppDriver on Agent | 聽
聽 | 聽 | 聽
聽 | Printing WinAppDriver Console logs: | 聽
聽 | 聽 | 聽
聽 | ##[debug]Caught exception from task script. | 聽
聽 | ##[debug]Error record: | 聽
聽 | ##[debug]Cannot find path 'C:\winappdriverlog.txt' because it does not exist. | 聽
聽 | ##[debug]    + CategoryInfo          : ObjectNotFound: (C:\winappdriverlog.txt:String) [], ItemNotFoundException | 聽
聽 | ##[debug]    + FullyQualifiedErrorId : PathNotFound | 聽
聽 | ##[debug] | 聽
聽 | ##[debug]Script stack trace: | 聽
聽 | ##[debug] | 聽
聽 | ##[debug]Exception: | 聽
聽 | ##[debug]System.Management.Automation.ItemNotFoundException: Cannot find path 'C:\winappdriverlog.txt' because it does not exist. | 聽
聽 | ##[debug]   at System.Management.Automation.LocationGlobber.ExpandMshGlobPath(String path, Boolean allowNonexistingPaths, PSDriveInfo drive, ContainerCmdletProvider provider, CmdletProviderContext context) | 聽
聽 | ##[debug]   at System.Management.Automation.LocationGlobber.ResolveDriveQualifiedPath(String path, CmdletProviderContext context, Boolean allowNonexistingPaths, CmdletProvider& providerInstance) | 聽
聽 | ##[debug]   at System.Management.Automation.LocationGlobber.GetGlobbedMonadPathsFromMonadPath(String path, Boolean allowNonexistingPaths, CmdletProviderContext context, CmdletProvider& providerInstance) | 聽
聽 | ##[debug]   at Microsoft.PowerShell.Commands.ContentCommandBase.ResolvePaths(String[] pathsToResolve, Boolean allowNonexistingPaths, Boolean allowEmptyResult, CmdletProviderContext currentCommandContext) | 聽
聽 | ##[error]Cannot find path 'C:\winappdriverlog.txt' because it does not exist. | 聽
聽 | ##[debug]Processed: ##vso[task.logissue type=error]Cannot find path 'C:\winappdriverlog.txt' because it does not exist. | 聽
聽 | ##[debug]Processed: ##vso[task.complete result=Failed]



@hassanuz Our most recent build ran with the 0.0.2 version of the task and did not hit this issue. I will let you know if we see it again; if not, consider it fixed. Thanks!
As for agent info, we were running on what I believe is a default Azure Pipelines agent using the windows-2019-vs2019 image. Its agent version was 2.154.3.

Thanks, do keep me posted @jalkire ! If all looks good, I will close this issue within 7 days.

##[error]Cannot find path 'C:\winappdriverlog.txt' because it does not exist.

Are you still seeing this error? How consistently are you seeing it? Thanks

I see that error every single run.

@alfonso-mireles - what type of agent are you running on (self-hosted, private, Windows version)? Are you passing in any arguments?

@hassanuz Self-Hosted on a VM. Windows 10. No arguments being passed.
I never encountered this issue until the latest change on the pipeline Task

@hassanuz Self-Hosted on a VM. Windows 10. No arguments being passed.
I never encountered this issue until the latest change on the pipeline Task

Investigating into it. Please reach out to me via hassan.[email protected] on the chance that I may need to provide a workaround Build.

Hi @alfonso-mireles, I pushed out a minor update - can you confirm if the issue is now resolved?

Thanks

@hassanuz Got the update from Friday. But the task is still finishes with the same Error

I'm closing this ticket as the original issue was resolved. @alfonso-mireles - please reach out to me via email for us to to directly look at your particular case. Thanks.

Closing this issue is a little premature IMO. The fix for this issue introduced a new bug that we're also seeing.
Also on a self hosted agent.
My extension settings are saying 0.0.1.7 is the latest version.

Closing this issue is a little premature IMO. The fix for this issue introduced a new bug that we're also seeing.
Also on a self hosted agent.
My extension settings are saying 0.0.1.7 is the latest version.

I am also blocked by this new issue.
Thank you

Was this page helpful?
0 / 5 - 0 ratings