【问题标题】:How to cache nuget packages for all projects in Azure Pipelines using Cache task如何使用缓存任务缓存 Azure Pipelines 中所有项目的 nuget 包
【发布时间】:2021-03-23 10:09:13
【问题描述】:

我正在使用以下步骤来执行解决方案级缓存:

- task: Cache@2
  inputs:
    key: 'nuget | "$(Agent.OS)" | $(Build.SourcesDirectory)/**/packages.lock.json'
    restoreKeys: |
       nuget | "$(Agent.OS)"
       nuget
    path: $(NUGET_PACKAGES)
  displayName: Cache NuGet packages    

- task: DotNetCoreCLI@2
  displayName: 'dotnet restore using package.lock.json'
  inputs:
    command: 'restore'
    restoreArguments: '--locked-mode'
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'

但是,在Post-job: Cache NuGet packages 中有警告:

##[警告]给定的缓存键在恢复和保存步骤之间的解析值发生了变化

我意识到这是因为在解析密钥时也会选择复制到输出目录 */bin/release/net5.0/packages.lock.json 文件的锁定文件。

我该如何解决这个问题?

【问题讨论】:

    标签: .net azure-devops nuget azure-pipelines .net-5


    【解决方案1】:

    通过在键中使用以下模式修复:

    key: 'nuget | "$(Agent.OS)" | **/packages.lock.json,!**/bin/**,!**/obj/**'
    

    【讨论】:

      猜你喜欢
      • 2020-10-06
      • 1970-01-01
      • 1970-01-01
      • 2021-01-28
      • 1970-01-01
      • 1970-01-01
      • 2011-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多