Azure Devops CI 测试适配器失败。强名称验证失败

Azure Devops CI Test Adapter fails. Strong Name Validation Failed

在执行我的 CI 构建时,管道失败并显示错误:

调用执行器 'executor://mstestadapter/v2' 时发生异常:无法加载文件或程序集 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 或其依赖项之一。强名称验证失败。 (HRESULT 异常:0x8013141A)

我的 YAML 的相关部分是

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

我正在使用 MSTest.TestAdapter v2.2.5,它是来自 nuget 的“最新稳定版”。从 Visual Studio.

构建并测试 运行

executor://mstestadapter/v2': Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed.

根据错误信息,您可以检查您是否使用.net core项目。

如果是,您可以使用.net core模板替换VSbuild模板,看看是否可以使用。

例如:

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

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '**/*.csproj'
    arguments: 'xxx'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: test
    projects: '**/*[Tt]ests/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'