【问题标题】:Azure Pipelines VS Test Task and .net 6Azure Pipelines VS 测试任务和 .net 6
【发布时间】:2021-12-13 10:09:13
【问题描述】:

有以下单元测试任务

pool:
  name: Azure Pipelines
  vmImage: 'windows-2022' # Needed for .NET6 'windows-latest' did not work 2021 Dec

(...)

- task: VSTest@2
  displayName: "Run unit tests"
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'

此任务不运行任何测试,它报告Could not load file or assembly 'System.Runtime, Version=6.0.0.0

[MSTest][Discovery][...] Failed to discover tests from assembly D:\a\1\s\aaa\bin\Release\net6.0\aaa.dll. Reason:Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

我的设置是

Starting: Initialize job
Agent name: 'Azure Pipelines 6'
Agent machine name: 'aaa'
Current agent version: '2.195.2'
Operating System
Virtual Environment
Virtual Environment Provisioner
Current image version: '20211206.1'
Agent running as: 'VssAdministrator'
Prepare build directory.
Set build variables.
Download all required tasks.
Downloading task: DotNetCoreCLI (2.187.0)
Downloading task: VSTest (2.195.0)
Downloading task: PublishPipelineArtifact (1.2.3)
Checking job knob settings.
   Knob: AgentToolsDirectory = C:\hostedtoolcache\windows Source: ${AGENT_TOOLSDIRECTORY} 
   Knob: AgentPerflog = C:\agents\perflog Source: ${VSTS_AGENT_PERFLOG} 
Finished checking job knob settings.
Start tracking orphan processes.
Finishing: Initialize job

如何让它运行我漂亮的测试?

【问题讨论】:

  • 你好 tymtam;在尝试对其进行单元测试之前,我可以仔细检查您的管道是否已经构建您的应用程序?
  • 是的,应用构建并发布成功。文物就在那里。
  • 另外,本地测试运行正常。

标签: .net azure-devops azure-pipelines .net-6.0


【解决方案1】:

在明确安装 .net 6 后,问题消失了 - 测试任务找到并运行测试。

steps:
- task: UseDotNet@2 # 2021-Dec Needed for running Unit Test, otherwise https://github.com/microsoft/azure-pipelines-tasks/issues/15607
  displayName: 'Install .net6 runtime (required for running Unit Tests only)'
  inputs:
    packageType: 'runtime'
    version: '6.x'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-19
    • 1970-01-01
    • 2020-05-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多