我复制了你的错误:
我解决这个问题的方法是:
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
然后添加
戈宾
到
PATH
.
- 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)