Azure DevOps 托管代理管道“无法找到可执行文件:‘Powershell’

kil*_*yte 6 deployment powershell azure-devops

Azure DevOps 部署代理(在我们的一台 Windows VM 上自托管)突然决定停止工作,并在执行该IIS Web App Deploy步骤时抛出此错误:

Error: Unable to locate executable file: 'powershell'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable.

最近还有其他人收到这个吗?

查看日志,有一条警告表明:

PowerShell Core (pwsh.exe) is not available on agent machine. Falling back to using Windows PowerShell (powershell.exe). This can cause reduced performance. Please install the newer version of PowerShell for improved performance.

此错误有些不对劲,因为 A) 我使用 Powershell 安装了代理,B) 我删除了代理,并在发生此错误后能够使用 PowerShell 重新安装它。

管道步骤本身与默认值没有变化,并且已经运行了多年,没有出现任何问题——这是从 DevOps 生成的 YAML,用于证明这一点(如果间距被 SO 弄乱了,我们深表歉意):

steps:
- task: IISWebAppDeploymentOnMachineGroup@0
  displayName: 'IIS Web App Deploy'
  inputs:
       WebSiteName: '$(Parameters.WebsiteName)'
       TakeAppOfflineFlag: True
       XmlVariableSubstitution: True
Run Code Online (Sandbox Code Playgroud)

小智 5

新版本打破了这一任务。

https://github.com/microsoft/azure-pipelines-tasks/issues/14595

添加 ADO_FORCE_USE_7ZIP=true 作为管道变量。

  • 我的问题就是这种情况。微软的支持帮助了我。谢谢! (2认同)

Hug*_*Lin 1

pwsh.exe 在代理计算机上不可用

IIS Web部署任务的版本最近已更新。该任务默认会检查是否有powershell 7。如果没有,就会出现这个警告。

在此输入图像描述

要解决此问题,您需要安装 powershell 7。安装Powershell 7并设置系统环境后,任务将使用Powershell 7。

设置系统环境:系统属性->环境变量。

在此输入图像描述

在此输入图像描述