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

Azure Pipeline通过Docker执行dotnet build不报告错误和警告的问题

.NET 7 Azure DevOps构建问题:无法在流水线摘要中查看具体dotnet错误

我有一个.NET 7解决方案,正在Azure DevOps流水线中通过PowerShell和Docker进行构建。当构建因任何原因失败(例如文件编译失败)或构建输出存在警告时,这些信息不会显示在Azure流水线的摘要页面上。我仅能在Docker构建日志部分看到错误,以及一条通用的“PowerShell exited with code '1'.”错误,但没有具体的dotnet错误,导致难以快速定位构建失败原因。我尝试了几种输出错误的方法,但均无法正常输出错误信息。

流水线输出情况

流水线摘要页面仅显示通用错误提示:“PowerShell exited with code '1'”,无具体的dotnet编译错误或警告详情

日志输出情况

Docker构建日志中包含具体的dotnet错误信息,但这些内容并未同步到流水线摘要页面

流水线YAML构建步骤

- task: PowerShell@2
  displayName: 'Docker: Build/Test/Publish'
  inputs:
    pwsh: true
    failOnStderr: true
    showWarnings: true
    targetType: 'inline'
    script: |
      docker compose -f "$(System.DefaultWorkingDirectory)/docker-compose.yml" --profile "api" build
      docker create -i -t --name utresults api
      docker cp utresults:/testresults $(System.DefaultWorkingDirectory)
      docker rm -fv utresults

docker-compose.yml配置

baseapi:
  image: ${DOCKER_REGISTRY-}api
  profiles: [ 'api' ]
  container_name: Api
  build:
     context: .
     dockerfile: Source/Docker/pipeline.Dockerfile

pipeline.Dockerfile内容

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base        
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:7.0 as build
RUN dotnet build Api.sln \
  --configuration Release \
  --framework net7.0

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.02 04:01:18