Azure管道无法在go get之后执行命令

Azure管道无法在go get之后执行命令,go,azure-pipelines,Go,Azure Pipelines,我想使用rsrc在我的azure devops管道中的windows Go应用程序中设置一个图标。 我想我遗漏了一些琐碎的东西,我的管道在go-get-u-v github.com/akavel/rsrc之后找不到命令rsrc 我的解决方法是在vcs中使用rsrc.exe 管道 错误 rsrc.exe:术语“rsrc.exe”未被识别为cmdlet、函数、脚本文件或可操作程序的名称。 请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试 更新 去安装github.com/akavel

我想使用
rsrc
在我的azure devops管道中的windows Go应用程序中设置一个图标。 我想我遗漏了一些琐碎的东西,我的管道在
go-get-u-v github.com/akavel/rsrc
之后找不到命令
rsrc

我的解决方法是在vcs中使用rsrc.exe

管道 错误 rsrc.exe:术语“rsrc.exe”未被识别为cmdlet、函数、脚本文件或可操作程序的名称。 请检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试

更新
  • 去安装github.com/akavel/rsrc
    没有帮助
  • $env:GOPATH
    为空

  • 我重复了你的错误:

    我解决这个问题的方法是:

    首先,在运行Go任务之前,您应该提前设置
    GOPATH
    GOBIN

    这里有一个例子

    variables:
      GOBIN:  '$(GOPATH)\bin' # Go binaries path
      GOPATH: '$(system.defaultWorkingDirectory)\gopath' # Go workspace path
      modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code
    
    然后将
    GOBIN
    添加到
    路径中

    - script: echo '##vso[task.prependpath]$(GOBIN)'
    
    所以完整的脚本应该是这样的:

    variables:
      GOBIN:  '$(GOPATH)\bin' # Go binaries path
      GOPATH: '$(System.DefaultWorkingDirectory)\gopath' # Go workspace path
      modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code
    
    steps:
    - task: Go@0
      displayName: Install rsrc
      condition: eq(variables['agent.os'], 'Windows_NT')
      inputs:
        command: 'get'
        arguments: '-u -v github.com/akavel/rsrc'
        workingDirectory: $(System.DefaultWorkingDirectory) 
    
    - script: echo '##vso[task.prependpath]$(GOBIN)'
    
    - task: PowerShell@2
      displayName: Generate syso files
      timeoutInMinutes: 1
      condition: eq(variables['agent.os'], 'Windows_NT')
      inputs:
        targetType: 'inline'
        script: |
          $icon = ([System.IO.Path]::Combine("$(System.DefaultWorkingDirectory)", "build/App.ico"))
          $iconSyso = ([System.IO.Path]::Combine("$(System.DefaultWorkingDirectory)", "cmd/myapp/rsrc.syso"))
          rsrc.exe -ico $icon -o $iconSyso
        workingDirectory: $(System.DefaultWorkingDirectory)  
    

    不熟悉Azure管道,但我认为问题在于
    go-get
    %GOPATH%\bin
    中安装
    rsrc.exe
    ,它不在
    %PATH%
    中,所以在
    PowerShell@2
    task您可能需要为其提供完整路径(或将%path%设置为包含%GOPATH%)?您也可以尝试
    go install
    ,因为
    go get
    并不总是安装程序GOPATH%\bin必须添加到%PATH%变量中,正如@blami所说。您好,这个问题有更新吗?请检查我下面的回答是否能帮助您,并随时发表评论。
    variables:
      GOBIN:  '$(GOPATH)\bin' # Go binaries path
      GOPATH: '$(System.DefaultWorkingDirectory)\gopath' # Go workspace path
      modulePath: '$(GOPATH)\src\github.com\$(build.repository.name)' # Path to the module's code
    
    steps:
    - task: Go@0
      displayName: Install rsrc
      condition: eq(variables['agent.os'], 'Windows_NT')
      inputs:
        command: 'get'
        arguments: '-u -v github.com/akavel/rsrc'
        workingDirectory: $(System.DefaultWorkingDirectory) 
    
    - script: echo '##vso[task.prependpath]$(GOBIN)'
    
    - task: PowerShell@2
      displayName: Generate syso files
      timeoutInMinutes: 1
      condition: eq(variables['agent.os'], 'Windows_NT')
      inputs:
        targetType: 'inline'
        script: |
          $icon = ([System.IO.Path]::Combine("$(System.DefaultWorkingDirectory)", "build/App.ico"))
          $iconSyso = ([System.IO.Path]::Combine("$(System.DefaultWorkingDirectory)", "cmd/myapp/rsrc.syso"))
          rsrc.exe -ico $icon -o $iconSyso
        workingDirectory: $(System.DefaultWorkingDirectory)