.net-core - 测试未在 Azure Devops 编译的 aspnet core 3.0 测试项目上运行

标签 .net-core azure-devops yaml azure-pipelines vstest

我有以下存储库 https://github.com/Mech0z/Foosball 在我有以下项目文件的地方,我希望管道中的测试步骤运行

https://github.com/Mech0z/Foosball/blob/master/Integrationstest/Integrationstest.csproj

它有以下包

<PackageReference Include="nunit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />

而我的yaml文件是这样的

- task: VSTest@2
  inputs:
    projects: '**/*/Integrationstest.csproj'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

但是当它运行时我得到

Test run will use DLL(s) built for framework .NETFramework,Version=v4.0 and platform X86. Following DLL(s) do not match framework/platform settings. Integrationstest.dll is built for Framework .NETCoreApp,Version=v3.0 and Platform AnyCPU.

如何更改 yaml 文件中的 .NET 框架?

最佳答案

不使用 VSTest 任务,而是使用 DotNetCore 任务来运行您的测试,例如

- task: DotNetCoreCLI@2
    inputs:
      command: "test"
      projects: "**/*/Integrationstest.csproj"
    displayName: Run the server-side tests

关于.net-core - 测试未在 Azure Devops 编译的 aspnet core 3.0 测试项目上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58522954/

相关文章:

amazon-web-services - 使用 AWS ebextensions,按文档传递命令数组的正确方法是什么?

javascript - SignalR 不会退回到旧协议(protocol)

c# - 如何根据 cookie 值将用户对象从启动类注入(inject)到 Controller 构造函数

git - 致命: git repository not found (but can go to URL) in Azure Devops?

azure-devops - 仅在 ARM 模板部署后才知道 ConnectionString 时如何生成 EF Core 迁移脚本?

azure - 将 Powershell 脚本中的值返回到 Azure DevOps 任务

ruby - 无法在 Ruby 中解析 "%YAML:1.0"

ruby - 在 DataMapper 中序列化和反序列化 Ruby 对象

c# - 将参数与 Func<> 一起使用

c# - 无法使用 .NET Core 在 Raspbian 上加载文件或程序集 'System.Diagnostics.DiagnosticSource'