.net 从构建或发布管道在azure devops中发布nuget包

.net 从构建或发布管道在azure devops中发布nuget包,.net,azure,.net-core,azure-devops,nuget,.net,Azure,.net Core,Azure Devops,Nuget,在azure devops中发布nuget包的正确位置在哪里?使用构建或发布管道更好吗 一种解决方案是只在构建中创建一个工件(zip),然后在发布版中下载它,然后创建一个nuget包 编辑 用条件任务解决了它: trigger: branches: include: - master - dev paths: include: - src/* - test/* - azure-pipelines.yml pr: branche

在azure devops中发布nuget包的正确位置在哪里?使用构建或发布管道更好吗

一种解决方案是只在构建中创建一个工件(zip),然后在发布版中下载它,然后创建一个nuget包

编辑

用条件任务解决了它:

trigger:
  branches:
    include:
    - master
    - dev
  paths:
    include:
    - src/*
    - test/*
    - azure-pipelines.yml

pr:
  branches:
    include:
    - '*'

pool:
  vmImage: 'ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
  displayName: 'Use dotnet sdk 3.x'
  inputs:
    version: 3.x
    includePreviewVersions: false

- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
  displayName: Build_release
  inputs:
    command: build
    projects: '**/*.csproj'
    arguments: '--configuration release'

- task: DotNetCoreCLI@2
  condition: ne(variables['Build.SourceBranch'], 'refs/heads/master')
  displayName: Build_Debug
  inputs:
    command: build
    projects: '**/*.csproj'
    arguments: '--configuration debug'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '**/*Test/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

- task: NuGetToolInstaller@1
  displayName: 'Install nuget 5.x'
  inputs:
    versionSpec: '5.x'

- task: NuGetCommand@2
  displayName: 'Pack nuget'
  inputs:
    command: 'pack'
    packagesToPack: 'src/**/*.csproj'
    packDestination: '$(Build.ArtifactStagingDirectory)'

- task: NuGetCommand@2
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/master')
  displayName: 'Push to nuget feed sample-cloud'
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: '<guid>'
    allowPackageConflicts: true

- task: NuGetCommand@2
  condition: eq(variables['Build.SourceBranch'], 'refs/heads/dev')
  displayName: 'Push to nuget feed sample-cloud-dev'
  inputs:
    command: 'push'
    packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
    nuGetFeedType: 'internal'
    publishVstsFeed: '<guid>/<guid>'
触发器:
分支机构:
包括:
-主人
-发展
路径:
包括:
-src/*
-试验/*
-azure-pipelines.yml
公共关系:
分支机构:
包括:
- '*'
游泳池:
vmImage:'ubuntu-16.04'
变量:
buildConfiguration:“发布”
步骤:
-任务:UseDotNet@2
displayName:“使用dotnet sdk 3.x”
投入:
版本:3.x
includePreviewVersions:false
-任务:DotNetCoreCLI@2
显示名称:还原
投入:
命令:还原
项目:“***.csproj”
-任务:DotNetCoreCLI@2
条件:eq(变量['Build.SourceBranch'],'refs/heads/master')
displayName:Build\u release
投入:
命令:build
项目:“***.csproj”
参数:'--配置发布'
-任务:DotNetCoreCLI@2
条件:ne(变量['Build.SourceBranch'],'refs/heads/master')
displayName:Build\u Debug
投入:
命令:build
项目:“***.csproj”
参数:'--配置调试'
-任务:DotNetCoreCLI@2
显示名称:测试
投入:
命令:test
项目:“***测试/*.csproj”
参数:'--configuration$(buildConfiguration)'
-任务:NuGetToolInstaller@1
displayName:“安装nuget 5.x”
投入:
版本规范:“5.x”
-任务:NuGetCommand@2
displayName:'Pack nuget'
投入:
命令:“打包”
包装包装:“src/***.csproj”
packDestination:“$(Build.ArtifactStagingDirectory)”
-任务:NuGetCommand@2
条件:eq(变量['Build.SourceBranch'],'refs/heads/master')
displayName:“推送到nuget提要示例云”
投入:
命令:“推”
packagesToPush:'$(Build.ArtifactStagingDirectory)/***.nupkg$(Build.ArtifactStagingDirectory)/***.symbols.nupkg'
nuGetFeedType:“内部”
publishVstsFeed:“”
allowPackageConflicts:true
-任务:NuGetCommand@2
条件:eq(变量['Build.SourceBranch'],'refs/heads/dev')
displayName:'推送到nuget提要示例云开发'
投入:
命令:“推”
packagesToPush:'$(Build.ArtifactStagingDirectory)/***.nupkg$(Build.ArtifactStagingDirectory)/***.symbols.nupkg'
nuGetFeedType:“内部”
publishVstsFeed:“/”
从构建或发布管道在azure devops中发布nuget包

这绝对是你个人的喜好,这是一个品味的问题,没有标准的要求或过程

一般来说,发布包的过程是:构建项目/解决方案->打包
.csproj
/
.nuspec
文件以生成nuget包->发布生成的包,我们不会故意将构建和发布过程拆分为
CI
CD
,因此,我们不需要额外的管道开销,也不需要在构建和发布管道之间传递工件

因此,我们可以通过NuGet任务生成包,并在构建管道中发布包

当然,如果包发布和CI、CD有严格的标准要求,我们需要在发布管道中发布包。例如,在构建管道中,我们生成预发布包,但如果要求我们只发布稳定版本包,在这种情况下,我们需要创建一个发布管道来发布稳定包,否则,我们必须在构建管道中手动启用/禁用推送任务


希望这能有所帮助。

只是想看看提供的信息是否有用。请告诉我们您是否需要进一步的帮助。@LeoLiu MSFT我现在使用条件任务推送到正确的提要。你认为这个解决方案怎么样?