I try to run dotnet tool install in Azure DevOps and test the tool.
Locally
dotnet tool install dotnetsay -g
dotnetsay test
works seamlessly.
In Azure DevOps this script:
- task: CmdLine@2
displayName: 'Install dotnetsay'
inputs:
script: 'dotnet tool install dotnetsay -g'
- task: CmdLine@2
displayName: 'Run dotnetsay'
inputs:
script: 'dotnetsay test'
returns error
/home/vsts/work/_temp/8a35f36d-4eff-4541-9aae-cf3f063f9180.sh: line 1: dotnetsay: command not found
##[error]Bash exited with code '127'.
I've tried already 3 different tools:
with the same result.
Is there any additional command to make dotnet tool available for Azure DevOps?
To make this work, I think you will need to add an initial UseDotNet task to setup the .NET SDK. Generally, this is a best practice that makes it clear which version you are expecting and ensures that you're building with that version. That process also ensures that your global tools will work as expected. The code:
- task: UseDotNet@2
enabled: true
inputs:
packageType: 'sdk'
version: 3.x
Let me know if that works for you. That said, there is an issue with running dotnetsay in Azure DevOps. That tool first checks to see if the input is redirected. If it is, it reads input from the console. The input and output for the Azure DevOps pipeline agent are redirected. Consequently, the task will block on this line awiting for an input. You will need to either cancel the Job or wait for it to time out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With