Reputation: 881
The Azure DevOps deployment agent (self-hosted on one of our Windows VMs) decided to stop working out of the blue, throwing this error when executing the IIS Web App Deploy
step:
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.
Has anyone else gotten this recently?
Reviewing the logs, there is a warning that indicates:
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.
Something is not right about this error, since A) I installed the agent using Powershell and B) I deleted the agent and was able to re-install it using PowerShell after this error occurred.
The pipeline step itself is unchanged from the default and has been running for years without a problem-- here is the YAML generated from DevOps to prove the point (apologies if spacing got messed up by SO):
steps:
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'IIS Web App Deploy'
inputs:
WebSiteName: '$(Parameters.WebsiteName)'
TakeAppOfflineFlag: True
XmlVariableSubstitution: True
Upvotes: 6
Views: 15381
Reputation: 1
You need to set azCLI
task exactly like this:
azureSubscription:
scriptType:
workingDirectory:
scriptLocation: inlineScript
inlineScript:
Upvotes: 0
Reputation: 19471
pwsh.exe is not available on the agent machine
The version of IIS web deploy task has been updated recently. The task will check whether there is powershell 7 by default. If not, there will be this warning.
To solve this, you need to install powershell 7. After installing Powershell 7 and set the system environment, the task will use Powershell 7 .
Set system env: System Properties -> Environment variables.
Upvotes: 1
Reputation: 11
Looks like IIS Web Deploy task is updated on Azre. In releases logs I can see that task version is no more 0.179.0, but 0.184.0: image
I have installed PowerShell Core (7.0.6) on host and restarted it. Not it works fine.
Upvotes: 1
Reputation: 61
The new release breaks this task.
https://github.com/microsoft/azure-pipelines-tasks/issues/14595
Add ADO_FORCE_USE_7ZIP=true as a pipeline variable.
Upvotes: 5
Reputation: 881
I was able to work around this problem by re-adding the default PowerShell installation directory path to the system PATH
as described here:
https://stackoverflow.com/a/29778651/4822220
And then re-starting the host.
This doesn't actually fix the issue, because there's still a warning in the Azure Pipeline log that pwsh.exe is not available on the agent machine
. Note that Powershell is installed in the default directory but the DevOps agent's deployment script was still unable to find it for some reason.
Upvotes: 0