1

当我构建我的测试解决方案(一组单元测试用例)时,我收到以下错误,需要在下面的 yaml 脚本中添加 timeoutinminutes。

[错误 1] 在代理 Hosted Agent 上运行的作业运行时间超过了 60 分钟的最长时间。有关详细信息,请参阅https://go.microsoft.com/fwlink/?linkid=2077134

在下面找到 yaml 脚本:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/**.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Debug'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
- task: VSTest@2
  timeoutInMinutes: 1200
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    runInParallel: true
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'
4

1 回答 1

2

我认为您感到困惑的应该是为什么您指定timeoutInMinutes1200,以及为什么仍然面临错误:

“在代理托管代理上运行的作业运行时间超过了 60 分钟的最长时间。”

正如DJ所说,错误信息中的链接已经给你解释了。

你的项目应该是私有的,对吧?如果是这样,那么您将无法避免私人项目托管代理的限制。

Microsoft 托管代理的功能和限制

公共项目: 10 个免费的 Microsoft 托管并行作业,每次可运行长达360分钟(6 小时)

私人项目:一个免费的并行作业,每次可以运行长达60分钟

尽管您将超时时间指定为 1200 分钟,但遗憾的是,它无法覆盖服务器的限制。


使您的测试不受超时限制的最佳解决方案是安装和使用私有代理

或者您认为360分钟对您来说已经足够了,那么您可以尝试将 change project as public。但如果您认为脚本和存储库对您来说非常私密,我不推荐这种方式。

于 2019-11-20T11:50:03.767 回答