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

Azure Pipeline构建C#项目未生成bin文件夹问题排查

问题:Azure CI/CD流水线构建后仅生成obj文件夹,无bin文件夹

我有一个包含多个项目的服务解决方案,需要通过Azure CI/CD流水线发布主项目。已配置Azure构建流水线,但生成工件时发现仅存在包含部署文件的obj文件夹,没有bin文件夹。以下是YAML定义和构建日志,请问该现象的可能原因是什么?

YAML 定义

pool:
  name: vjAppPool
  demands: msbuild

variables:
  BuildPlatform: 'Any CPU' --Used for solution
  BuildConfiguration: 'Release'
  BuildPlatform_Proj:'AnyCPU' --Used for csproject

steps:
- task: NuGetToolInstaller@1
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1


- task: MSBuild@1
  displayName: 'Build  service project'
  inputs:
    solution: '$/VjTS/Main/vjApp-DEV-3.2.0/Vj.vjApp.Services.Web/Vj.vjApp.Services.Web.csproj'
    msbuildArchitecture: x64
    platform: '$(BuildPlatform_Proj)'
    configuration: '$(BuildConfiguration)'
    msbuildArguments: '/t:Restore /p:SkipInvalidConfigurations=true /p:DebugType=full /p:WebPublishMethod=Package /p:PackageLocation="$(build.artifactstagingdirectory)"'
    clean: true

- task: PublishSymbols@2
  displayName: 'Publish symbols path'
  inputs:
    SearchPattern: '**/bin/**/*.*'
    SymbolServerType: TeamServices
    SymbolExpirationInDays: 365
    IndexableFileFormats: All
    SymbolsArtifactName: '$(BuildConfiguration)'
  continueOnError: true


- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'

构建服务项目日志

##[debug] FileName: 'C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\msbuild.exe'
##[debug] Arguments: '"C:\AgentPool_work\4\s\Vj.App.Services.Web.csproj" /nologo /nr:false
/t:"Clean"
/dl:CentralLogger,"C:\AgentPool_work_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=C:\AgentPool_work\4\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"C:\AgentPool_work_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"
/t:Restore /p:SkipInvalidConfigurations=true /p:DebugType=full
/p:WebPublishMethod=Package
/p:PackageLocation="C:\AgentPool_work\4\a" /p:platform="AnyCPU"
/p:configuration="Release"
/p:_MSDeployUserAgent="VSTS_cfbbcadb-2ff1-4896-b19c-651bf91799fa_build_38_0"'
##[debug] RequireExitCodeZero: 'True' "C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\msbuild.exe"
"C:\AgentPool_work\4\s\Vj.App.Services.Web.csproj" /nologo /nr:false
/t:"Clean"
/dl:CentralLogger,"C:\AgentPool_work_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll";"RootDetailId=|SolutionDir=C:\AgentPool_work\4\s|enableOrphanedProjectsLogs=true"*ForwardingLogger,"C:\AgentPool_work_tasks\MSBuild_c6c4c611-aa2e-4a33-b606-5eaba2196824\1.231.5\node_modules\azure-pipelines-tasks-msbuildhelpers\tools\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"
/t:Restore /p:SkipInvalidConfigurations=true /p:DebugType=full
/p:WebPublishMethod=Package
/p:PackageLocation="C:\AgentPool_work\4\a" /p:platform="AnyCPU"
/p:configuration="Release"
/p:_MSDeployUserAgent="VSTS_cfbbcadb-2ff1-4896-b19c-651bf91799fa_build_38_0"
Build started 16-01-2024 16:51:57 PM.

Project "C:\AgentPool_work\4\s\Vj.App.Services.Web.csproj" on node 1
(Clean;Restore target(s)). CoreClean: Creating directory
"obj\Release".

可能原因分析

  • MSBuild目标缺失Build动作:当前MSBuild任务的/t参数仅指定了Restore,加上任务配置的clean: true会触发Clean目标,但未明确添加Build或Publish目标。Web项目的WebPublishMethod=Package依赖编译结果,缺少Build目标会导致仅执行清理和还原,不会编译生成bin文件夹。
  • 平台参数格式不一致:变量BuildPlatform是Any CPU(带空格),BuildPlatform_Proj是AnyCPU(无空格),虽然MSBuild通常兼容两种格式,但部分项目配置可能因平台名称不匹配,导致编译输出路径异常,无法生成bin目录。
  • 构建日志不完整:提供的日志仅显示到Clean和Restore阶段,无后续编译步骤信息,可能是构建过程中出现未捕获的错误,导致Build阶段未执行,仅完成了前期的Clean和Restore动作。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 03:05:10