【问题标题】:Azure DevOps YAML - .Net Core CLI can't pack using internal artifact feedAzure DevOps YAML - .Net Core CLI 无法使用内部工件源打包
【发布时间】:2019-11-13 08:17:33
【问题描述】:

我正在尝试使用 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'

【问题讨论】:

    标签: .net-core azure-devops yaml azure-pipelines asp.net-core-cli


    【解决方案1】:

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

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

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

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

    【讨论】:

      【解决方案2】:

      您无需在pack 命令中指定提要。

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

      关于命令的更多信息以及可以使用哪些选项,你可以罚款here

      【讨论】:

        猜你喜欢
        • 2019-11-18
        • 1970-01-01
        • 2019-04-20
        • 2019-11-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多