Azure DevOps YAML - .Net Core CLI 无法使用内部工件提要进行打包

Azure DevOps YAML - .Net Core CLI can't pack using internal artifact feed

我正在尝试使用 YAML 通过 .Net Core CLI 在 Azure DevOps 中恢复、构建、打包和推送。

Restore 了解内部提要,但 pack 不知道。

如何将内部提要添加到打包操作中?

parameters:
  projects: ''

steps:
- task: DotNetCoreCLI@2
  displayName: "ProvisionRestoreProjects"
  inputs:
    command: 'restore'
    projects: '${{ parameters.projects }}'
    feedsToUse: 'select'
    vstsFeed: '/4d73414a-a21f-4f84-9355-90beadaf0a6e'

- task: DotNetCoreCLI@2
  displayName: "ProvisionBuildProjects"
  inputs:
    command: 'build'
    projects: ${{ parameters.projects }}
    arguments: '--configuration release  --no-cache'

- task: DotNetCoreCLI@2
  displayName: "ProvisionPackProjects" 
  inputs:
    command: 'pack'
    projects: ${{ parameters.projects }}
    versioningScheme: 'byEnvVar'
    versionEnvVar: 'NugetVersion'
    feedsToUse: 'select'
    vstsFeed: '/4d73414a-a21f-4f84-9355-90beadaf0a6e'

- task: DotNetCoreCLI@2
  displayName: "ProvisionPushProjects"
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg'
    feedsToUse: 'select'
    vstsFeed: '/4d73414a-a21f-4f84-9355-90beadaf0a6e'

您不需要在 pack 命令中指定 Feed。

pack命令只是将文件打包到.nupkg文件(NuGet包),然后将其推送到您的提要。

有关命令和可以使用的选项的更多信息,您可以 here

pack 命令“builds the project and creates NuGet packages”,这就是它试图再次恢复包的原因。

为防止这种情况,请将 nobuild: true 添加到任务输入中:

- task: @DotNetCoreCLI@2
  displayName: Pack
  inputs:
    command: pack
    nobuild: true

它将不再尝试重建项目本身,而是使用在前面的步骤中创建的工件。