Azure CI 管道 - DotNetCoreCLI@2 任务错误

Bha*_*anu 7 azure-devops azure-pipelines dotnetcorecli

我使用 .NET Core 3.1.0 开发了 WebAPI 项目,并使用 XUnit 开发了集成测试。

我在 Azure DevOps CI Pipeline (azure-pipelines.yaml) 中添加了以下任务来运行集成测试项目。

 - task: DotNetCoreCLI@2
   displayName: 'Run API integration tests - $(buildConfiguration)'
   inputs:
    command: 'test'
    arguments: '--configuration $(buildConfiguration)'
    publishTestResults: true
    projects: '**/IntegrationTests/IntegrationTests.csproj'
Run Code Online (Sandbox Code Playgroud)

我在管道执行期间收到以下错误。如何解决此错误?

##[error] 错误:进程 '/usr/bin/dotnet' 失败,退出代码为 1

##[警告].NET 5 与较旧的 Nuget 版本(<=5.7)存在一些兼容性问题,因此如果您使用较旧的 Nuget 版本(而不是 dotnet cli)进行还原,则使用 dotnet cli 命令(例如 dotnet build)依赖于这种恢复的包可能会失败。要减轻此类错误,您可以:(1) - 使用 dotnet cli 进行还原,(2) - 使用 Nuget 5.8 版进行还原,(3) - 使用 global.json 使用较旧的 sdk 版本 (<=3) 进行构建

信息:Azure Pipelines 托管代理已更新,现在包含 .Net 5.x SDK/Runtime 以及当前为 lts 的旧 .Net Core 版本。除非您已锁定项目的 SDK 版本,否则可能会选择 5.x SDK,与以前的版本相比,该版本可能具有破坏性行为。您可以在此处了解有关重大更改的更多信息:https : //docs.microsoft.com/en-us/dotnet/core/tools/https://docs.microsoft.com/en-us/dotnet/core/compatibility / . 要了解更多此类更改和故障排除,请参阅此处:https : //docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops# troubleshooting

##[error]Dotnet 命令失败,以下项目的退出代码为非零:/home/vsts/work/1/s/src/IntegrationTests/IntegrationTests.csproj

小智 0

我遇到了完全相同的问题,不同之处在于我的解决方案由 .net5 应用程序和 .netcore3.1 应用程序组成。

我能够通过在 azure 管道中指定较新的 dotnet 运行时来解决此问题:

- task: UseDotNet@2
  inputs:
    version: '5.0.x'
    packageType: runtime
Run Code Online (Sandbox Code Playgroud)