【问题标题】:Azure DevOps dotnet test fails with ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1Azure DevOps dotnet 测试失败并出现 ##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
【发布时间】:2020-06-28 14:56:41
【问题描述】:

我有 AzureDevops 管道来构建和测试我的 .net 核心 Azure Functions 解决方案。本地测试运行良好,但在构建代理时确实失败(我尝试了不同的代理)

这是错误日志:

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\BuildAgent\_work\20\s\UnitTestProject\UnitTestProject.csproj
##[section]Finishing: Test

错误:

这是我的 yaml 文件:

trigger:
- dev

pool: 'SelfHosted'

variables:
  workingDirectory: '$(System.DefaultWorkingDirectory)/'

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

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--output $(System.DefaultWorkingDirectory)/publish_output --configuration Release'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: 'test'
    projects: '**/*.csproj'
    publishTestResults: false

请建议,提前谢谢!

【问题讨论】:

  • 发布包含特定编译错误的其余错误日志。
  • AssemblyInfo 源代码是项目的一部分吗?
  • 您是否尝试过阅读输出中的错误消息?确切地告诉你问题是什么?
  • 嗨,您尝试过以下解决方案吗,效果如何?

标签: .net-core azure-devops azure-functions


【解决方案1】:

在调查上述 cs0579 重复 AssemblyInfo 错误时。可能是因为测试过程单独提供了汇编信息,又生成了另一个AssemblyInfo.cs文件,造成了重复。

您可以尝试以下方法以确保这些程序集信息在您的项目中仅声明一次。

1、从您的项目中删除 AssemblyInfo.cs 文件以防止重复冲突。

2,您可以尝试在 .csproj 文件中添加以下行

<PropertyGroup>
  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

请查看此similar thread 以获得更多可能的修复

【讨论】:

    【解决方案2】:

    我的自动化代码使用 CI 构建管道时遇到了类似问题。我正在使用“.Net Core”任务进行测试。

    解决方案

    1. 我将“测试”执行任务从 .Net Core 切换到了“Visual Studio 测试”。
    2. 在“测试文件”下的 VSTest 任务中,我指定了包含测试用例的确切项目名称。而不是主要的solution.dll。如图所示。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-30
      • 2019-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-06
      相关资源
      最近更新 更多