chocolatey-community / chocolatey-azuredevops

Chocolatey Extension for Azure DevOps
MIT License
20 stars 11 forks source link

choco install error #50

Open ashishchettri opened 4 years ago

ashishchettri commented 4 years ago

Expected Behavior

I am trying to install a package but keep getting a "##[error]Cannot bind argument to parameter 'Path' because it is null". The yaml is as follows:

- task: ChocolateyCommand@0
  inputs:
    command: 'install'
    installPackageId: 'sonarscanner-msbuild-net46'
    installForce: true

What I expected was it to run the way choco install sonarscanner-msbuild-net46 --force works when installing the package directly using powershell.

Current Behavior

I get a "##[error]Cannot bind argument to parameter 'Path' because it is null".

Possible Solution

I went ahead and installed chocolatey using the default powershell commands -

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |      
      Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
      SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin" 
      $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") 

Steps to Reproduce (for bugs)

  1. Add the task
  2. Select action as 'Install'
  3. Choose any package to install. e.g. azure-cli
  4. Execute the pipeline

Context

We are using chocolatey to install a sonarscanner so that we can run static analysis.

Your Environment

gep13 commented 4 years ago

@ashishchettri thanks for reaching out.

I am a little confused by this issue, and I want to make sure that we are talking about the same thing. You start the issue by saying that there is an error when attempting the installation of the sonarscanner package, and then you talk about installing Chocolatey via the default PowerShell command.

Assuming that you are using the Hosted Azure Build Agent, installing Chocolatey should not be required, as Chocolatey is already installed on the base image. If you are not running on a Hosted Azure Build Agent, then as per the note here: https://github.com/gep13/chocolatey-azuredevops#tasks you will need another Task to perform the installation of Chocolatey.

If you can elaborate on exactly the problem that you are having, hopefully we will be able to help you.