安装并在Azure DevOps中运行Go包任务。

huangapple go评论81阅读模式
英文:

Install and run go package task in Azure Dev Ops

问题

我想在将其打包为vsix扩展之前,剪裁我们的node_modules文件夹中的不必要的冗余内容。

这个工具node-prune很好用。在本地运行时,我使用chocolatey安装了它,但是在使用Azure DevOps作为我们的CI流程的一部分安装时,出现了node-prune未找到的问题。

- 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)'
英文:

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

得分: 2

为管道设置GO变量:

variables:
  GOBIN:  '$(GOPATH)/bin' # Go二进制文件路径
  GOROOT: '/usr/local/go1.10' # Go安装路径
  GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go工作区路径

看起来当前的PATH中找不到node-prune,你分享了YAML文件的一部分。

node-prune必须在你的本地工作,因为GOPATH已经定义,并且新的Go二进制文件存在于GOPATH/bin下。

英文:

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

huangapple
  • 本文由 发表于 2022年8月16日 00:37:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/73363936.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定