VSTS Release Failing due to file in use on remote server

时间:2017-04-06 17:15:37

标签: c# visual-studio iis azure-pipelines

Before I state the question I am aware this may be more of a server administration question however I am seeking an answer that involves fixing / modifying the VSTS release process instead of dealing with server permissions (I don't believe this is a server issue).

I have a VSTS Build definition and Release definition. The release definition copies the files from the build to a remote server (an IIS site).

My problem is that this process fails roughly 60% of the time.

Log files showing failure error:

2017-04-06T17:06:07.3886551Z Executing the powershell script: D:\BuildAgent\agent\tasks\IISWebAppDeploy\1.4.3\Main.ps1
2017-04-06T17:06:07.5605268Z Starting deployment of IIS Web Deploy Package : \\server01\Deploy\patrol\dev\rest_service\822\822.zip
2017-04-06T17:06:07.6542742Z Performing deployment in parallel on all the machines.
2017-04-06T17:06:07.6542742Z Deployment started for machine: SERVER01 with port 5985.
2017-04-06T17:06:27.9820654Z Deployment status for machine SERVER01 : Failed
2017-04-06T17:06:28.0133029Z Deployment failed on machine SERVER01 with following message : System.Exception: Error Code: ERROR_FILE_IN_USE
2017-04-06T17:06:28.0445759Z ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Deployment on one or more machines failed.
2017-04-06T17:06:28.0445759Z ##[error]For more info please refer to http://aka.ms/iisextnreadme

I circumvate the problem by manually remoting into the server and deleting the contents of the target directory manually. I've discovered that each time the release is failing, my manual delete causes a warning to popup that an .exe file is being used by another process. My suspicion is that this is the reason the release is failing.

Is there some extra step that can be added to a release to force delete / clear the target directory?

1 个答案:

答案 0 :(得分:0)

您可以使用Windows Machine File Copy任务将文件从构建复制到远程服务器。并选择清理目标,以便在将文件复制到远程服务器之前,它将首先清理目标目标文件夹。

enter image description here