根据代理中安装的内容,有几个选项。
托管代理附带的PowerShell版本足够新,可以使用
Expand-Archive
PowerShell function
。而且
7z
安装了,所以你也可以调用它。
- script: |
7z x path-to-downloaded-file.zip path-to-extract-to
path-to-extract-to\myexecutable.exe
# PowerShell
# Run a PowerShell script on Linux, macOS, or Windows
- task: PowerShell@2
inputs:
targetType: inline
#filePath: # Required when targetType == FilePath
#arguments: # Optional
script: |
Expand-archive -file path-to-downloaded-file.zip -Destinationpath path-to-extract-to
& path-to-extract-to\myexecutable.exe
#errorActionPreference: 'stop' # Optional. Options: default, stop, continue, silentlyContinue
#warningPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#informationPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#verbosePreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#debugPreference: 'default' # Optional. Options: default, stop, continue, silentlyContinue
#failOnStderr: false # Optional
#ignoreLASTEXITCODE: false # Optional
pwsh: true
#workingDirectory: # Optional
然后是内置任务:
# Extract files
# Extract a variety of archive and compression files such as .7z, .rar, .tar.gz, and .zip
- task: ExtractFiles@1
inputs:
#archiveFilePatterns: '**/*.zip'
destinationFolder:
#cleanDestinationFolder: true
#overwriteExistingFiles: false
#pathToSevenZipTool:
https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/extract-files?view=azure-devops