如何在 Azure devops 管道中的 yaml 任务上指定 Cake.Tool 版本

How to specify Cake.Tool version on yaml task in Azure devops pipelines

我有这个 yaml 任务到 运行 一个 build.cake 文件。

- task: cake-build.cake.cake-build-task.Cake@2
  displayName: 'Build Sources'
  inputs:
    script: devops/build.cake
    target: Default
    verbosity: Normal
    arguments: '--Configuration="$(build.configuration)" --Platform="$(build.platform)" --artifactsPath="$(Build.ArtifactStagingDirectory)"'
    

执行此任务时,它始终会安装最新版本的 Cake.Tool。这是管道日志的一部分:

2021-10-25T20:52:28.6148998Z ==============================================================================
2021-10-25T20:52:28.6149081Z Task         : Cake
2021-10-25T20:52:28.6149119Z Description  : Build with Cake
2021-10-25T20:52:28.6149153Z Version      : 2.1.0
2021-10-25T20:52:28.6149199Z Author       : Patrik Svensson
2021-10-25T20:52:28.6149233Z Help         : [More Information about Cake](https://cakebuild.net)
2021-10-25T20:52:28.6149267Z ==============================================================================
2021-10-25T20:52:29.0331876Z =====================================================
2021-10-25T20:52:29.0332236Z Root = D:\Agents[=12=]\_work5\s\devops
2021-10-25T20:52:29.0332411Z Tools = D:\Agents[=12=]\_work5\s\devops\tools
2021-10-25T20:52:29.0332915Z Cake Tool Path = D:\Agents[=12=]\_work5\s\devops\tools\dotnet-cake.exe
2021-10-25T20:52:29.0334592Z Package Feed = 
2021-10-25T20:52:29.0335733Z Running with system diagnostics
2021-10-25T20:52:29.0336048Z =====================================================
2021-10-25T20:52:29.0339302Z Installing Cake Tool (Latest)...
2021-10-25T20:52:29.0577395Z [command]"C:\Program Files\dotnet\dotnet.exe" tool install --tool-path D:\Agents[=12=]\_work5\s\devops\tools/ Cake.Tool
2021-10-25T20:52:37.3622249Z You can invoke the tool using the following command: dotnet-cake
2021-10-25T20:52:37.3622761Z Tool 'cake.tool' (version '1.3.0') was successfully installed.
2021-10-25T20:52:37.3766624Z 

在本例中,它安装了 1.3.0 版。如何修复此版本号?例如,如何告诉它始终使用 1.0.0 版。我还没有找到这方面的任何文档。

您应该可以使用版本 属性

指定版本
- task: cake-build.cake.cake-build-task.Cake@2
  displayName: 'Build Sources'
  inputs:
    version: 1.0.0
    script: devops/build.cake
    target: Default
    verbosity: Normal
    arguments: '--Configuration="$(build.configuration)" --Platform="$(build.platform)" --artifactsPath="$(Build.ArtifactStagingDirectory)"'