You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure DevOps Pipeline仅发布部分Web项目,Web API未打包到drop工件

问题根因
  • 现有Pipeline的DotNetCoreCLI@2发布任务未显式指定需要发布的项目路径,默认的路径匹配规则未覆盖services目录下的Web API项目,导致这两个项目被跳过
  • 多项目同时发布到同一个输出目录时,未配置独立打包规则,可能出现后发布的项目产物覆盖前面项目产物的问题
  • 两个Web API项目的.csproj配置文件中可能存在<IsPublishable>false</IsPublishable>配置,导致发布步骤自动跳过该类项目
修复步骤
  1. 检查Web API项目配置
    打开\services\api1\api.csproj和\services\api2\api2.csproj文件,确认不存在<IsPublishable>false</IsPublishable>配置项,如有则删除该行或者将值修改为true。

  2. 修改Pipeline发布任务配置
    更新原有发布任务,显式指定需要发布的项目路径,同时配置单文件打包规则,避免产物覆盖。修改后的完整Pipeline YAML如下:

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2 
  displayName: ".NET Core 6"
  inputs:
    version: '6.0.x'
    packageType: sdk

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    restoreSolution: '**/*.sln'
    feedsToUse: 'select'
    vstsFeed: 'f5775ae3-da0e-4b38-82f0-ce288b91309b'

- task: DotNetCoreCLI@2
  displayName: "Publish All Projects"
  inputs:
    command: 'publish'
    # 显式匹配所有项目,可根据需要自行增删匹配规则排除不需要发布的项目
    projects: |
      **/*.csproj
      !**/*Test*.csproj
    arguments: '-r win-x64 --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true'

# 可选:添加目录查看步骤,排查发布产物生成情况
- task: CmdLine@2
  displayName: "Check Publish Artifacts"
  inputs:
    script: dir $(Build.ArtifactStagingDirectory) /s

- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(Build.ArtifactStagingDirectory)'
    artifactName: 'drop'

内容的提问来源于stack exchange,提问作者Zoinky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 23:15:04