Install and run go package task in Azure Dev Ops

Viewed 47

I want to prune our node_modules folder of unnecessary bloat before it is packaged as a vsix extension.

This tool works well node-prune. Running locally I installed it with chocolatey - but trying to install it as part of our CI pipeline with Azure Dev ops - I get node-prune not found.

      - task: GoTool@0
        displayName: Install Go
        inputs:
          version: '1.10' 

      - task: Go@0
        displayName: Install Node-Prune
        inputs:
          command: 'get'
          arguments: 'github.com/tj/node-prune'

      - task: Go@0
        displayName: Prune Node Modules
        inputs:
          command: 'custom'
          customCommand: 'node-prune'
          arguments: '$(projectDirectory)'
1 Answers

Set the GO variables for the pipeline:

variables:
  GOBIN:  '$(GOPATH)/bin' # Go binaries path
  GOROOT: '/usr/local/go1.10' # Go installation path
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path

It seems that node-prune is not found in the current PATH, you shared a part of the YAML file.

node-prune must work in your local since the GOPATH is already defined, and new Go binaries exist under GOPATH/bin

Related