Azure Devops 中的集成测试超时 - 卡在将数据写入文件 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\

Integration tests timing out in Azure Devops - stuck on Writing data to file 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\

我在 Azure Devops 中遇到 运行ning 集成测试问题。所有测试 运行 在本地只需几秒钟(通过 dotnet test 或在 Visual Studio 中)但在 Devops 中它们会在一个小时后超时。

DevOps 步骤的 YAML 如下所示:

steps:
- task: DotNetCoreCLI@2
  displayName: 'Run Integration Tests'
  inputs:
    command: test
    projects: |
     **/*.IntegrationTests.csproj
     !**/obj/**

查看日志,问题似乎出现在以下几行之后:

A total of 1 test files matched the specified pattern. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0] User profile is available. Using 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58] Creating key {05e22f2e-8a73-4956-ab90-d0c010ad8b20} with creation date 2019-11-28 13:25:47Z, activation date 2019-11-28 13:25:47Z, and expiration date 2020-02-26 13:25:47Z. info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[58] Creating key {af3f23c1-c5a0-4d1c-8502-731a21a06827} with creation date 2019-11-28 13:25:47Z, activation date 2019-11-28 13:25:47Z, and expiration date 2020-02-26 13:25:47Z. info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39] Writing data to file 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\key---redacted---.xml'. info: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[39] Writing data to file 'C:\Users\VssAdministrator\AppData\Local\ASP.NET\DataProtection-Keys\key---redacted---.xml'.

我有单元测试 运行 在相同设置的单独步骤下成功(不同项目但相同 language/framework)。我的测试在内存数据库中使用 CustomWebApplicationFactory 和 EF-Core - 但同样在本地 运行 秒内完成所有操作。包含测试的项目是 C# .Net Core 2.2 项目。

我正在使用托管代理。

我设法通过使用 dotnet 测试命令(使用 --no-build)而不是 VSTest 步骤找到了解决方案。