Azure devops Azure开发人员操作测试步骤未找到测试(.net 5)

Azure devops Azure开发人员操作测试步骤未找到测试(.net 5),azure-devops,nunit,.net-5,Azure Devops,Nunit,.net 5,我有一个简单的.NET5项目,其中包含一个主项目和一个带有nUnit3测试的单元测试项目。在我的机器上(带有VisualStudio for mac fwiw的mac),测试是按预期的方式在构建和工作时发现的 当我尝试在Azure dev ops中设置构建管道时,没有发现我的任何测试,我在日志中看到以下行: Test run detected DLL(s) which were built for different framework and platform versions. Follow

我有一个简单的.NET5项目,其中包含一个主项目和一个带有nUnit3测试的单元测试项目。在我的机器上(带有VisualStudio for mac fwiw的mac),测试是按预期的方式在构建和工作时发现的

当我尝试在Azure dev ops中设置构建管道时,没有发现我的任何测试,我在日志中看到以下行:

Test run detected DLL(s) which were built for different framework and platform versions. Following DLL(s) do not match current settings, which are .NETFramework,Version=v4.0 framework and X86 platform.

GenericRepositoryTests.dll is built for Framework .NETCoreApp,Version=v5.0 and Platform AnyCPU.
Microsoft.TestPlatform.CommunicationUtilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
它报告了更多的Microsoft DLL,但你知道了。以下是构建过程的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:
- main

pool:
  vmImage: 'windows-latest'

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

steps:
# Added this step manually
- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.100'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'
    includePreviewVersions: true
# Added this step manually
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: restore
    projects: '**/*.csproj'
- 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
  inputs:
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test*.dll
      !**\*TestAdapter.dll
      !**\obj\**
    searchFolder: '$(System.DefaultWorkingDirectory)'
    codeCoverageEnabled: true
如何确保Azure开发人员操作测试运行程序设置已设置为运行.net 5 DLL

谢谢

请尝试安装
,然后检查结果

请参阅:了解更多解决方法。

请尝试安装
,然后检查结果

请参阅:了解更多解决方法。

由于我发现我需要的答案是使用dotnet test而不是VSTest:

这是我的最后一条管道:

trigger:
- main

pool:
  vmImage: 'windows-latest'

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

steps:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.100'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'
    includePreviewVersions: true

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

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    command: 'build'
    projects: '**/*.sln'

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: 'test'
    projects: '**/*tests.csproj'
    arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
    testRunTitle: 'Generic Repository Tests'
感谢您,我发现我需要的答案是使用dotnet test而不是VSTest:

这是我的最后一条管道:

trigger:
- main

pool:
  vmImage: 'windows-latest'

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

steps:

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.100'
  inputs:
    packageType: 'sdk'
    version: '5.0.100'
    includePreviewVersions: true

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

- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    command: 'build'
    projects: '**/*.sln'

- task: DotNetCoreCLI@2
  displayName: 'dotnet test'
  inputs:
    command: 'test'
    projects: '**/*tests.csproj'
    arguments: '--configuration $(buildConfiguration) --collect "Code coverage"'
    testRunTitle: 'Generic Repository Tests'

试试运行“dotnet测试”吧。@jessehouwing,成功了,谢谢!试试运行“dotnet测试”吧。@jessehouwing,成功了,谢谢!当我遇到这个问题时,我已经在使用nUnit测试适配器的那个版本了。在测试中使用dotnet CLI而不是VSTest runner已经解决了这个问题(正如jessehouwing在我的问题评论中所建议的),我很高兴听到dotnet测试可以解决这个问题,并感谢您在这里分享它。当我遇到这个问题时,我已经在使用nUnit测试适配器的那个版本了。使用dotnet CLI而不是VSTest runner解决了这个问题(正如jessehouwing在对我的问题的评论中所建议的),我很高兴听到dotnet测试可以解决这个问题,并感谢您在这里分享它。您好,感谢您的分享,您可以,它可以帮助其他遇到同样问题的社区成员,谢谢。嗨,谢谢分享,你可以,它可以帮助其他社区成员谁得到同样的问题,谢谢。