简体   繁体   English

Azure Devops 无法在同一 CI 任务中运行 .NET 框架和 dotnet 核心单元测试

[英]Azure Devops can't run .NET Framework and dotnet core unit test in the same CI task

I have a solution with .NET framework / .NET Core projects.我有一个 .NET 框架/.NET 核心项目的解决方案。

  • library.csproj (.net standard) library.csproj(.net 标准)
  • library.UnitTests.csproj (.net framework) library.UnitTests.csproj(.net 框架)
  • WebApi.csproj (.net core) WebApi.csproj(.net 核心)
  • WebApi.UnitTests.csproj (.net core) WebApi.UnitTests.csproj(.net 核心)

And I have a CI build via AzureDevops to export coverage on SonarQube.我通过 AzureDevops 构建了一个 CI,以导出 SonarQube 上的覆盖率。

So, after running, I got this error:所以,运行后,我得到了这个错误:

Test run will use DLL(s) built for framework .NETFramework,Version=v4.0 and platform X64测试运行将使用为框架 .NETFramework、Version=v4.0 和平台 X64 构建的 DLL
Following DLL(s) do not match framework/platform settings.以下 DLL 与框架/平台设置不匹配。
WebApi.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU. WebApi.UnitTests.dll 是为 Framework 2.2 和 Platform AnyCPU 构建的。

I tried to split pipeline into two steps then it works, but i lost the fist step code coverage.(Can't do much things related to sonarQube).我试图将管道分成两个步骤然后它可以工作,但我失去了第一步代码覆盖率。(不能做很多与 sonarQube 相关的事情)。

Any idea to run tests together in the same task?有什么想法可以在同一个任务中一起运行测试吗? Or any another way to do that?或者任何其他方式来做到这一点?

The reason for this problem may be that the UnitTests.dll in your project is built for Framework 2.2 and Platform AnyCPU, but in the UnitTest task, Framework 4.0 and Platform x64 is used.出现这个问题的原因可能是你项目中的UnitTests.dll是为Framework 2.2和Platform AnyCPU构建的,但是在UnitTest任务中使用的是Framework 4.0和Platform x64。 You can add a /Framework parameter to solve this question.您可以添加/Framework参数来解决此问题。

/Framework:.NETCoreApp,Version=v2.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 Azure Devops 上使用 DotNetCoreCLI 任务恢复.Net Core 解决方案 - Can't restore .Net Core solution with DotNetCoreCLI task on Azure Devops dotnet核心:无法运行单元测试 - dotnet core: can't run unit tests .net 核心单元测试项目未能在 Azure Devops 管道中构建 - .net core unit test project failing to build in Azure Devops pipeline 在同一解决方案文件中同时包含 .NET Framework 和 .NET Core 项目的 Azure DevOps 中构建 .sln - Building .sln in Azure DevOps that has both .NET Framework and .NET Core projects in the same solution file Azure DevOps - 无法运行已安装的 dotnet 工具 - Azure DevOps - cannot run installed dotnet tool 如果.Net Core可以在Windows上运行,为什么不能在.Net Framework中引用.Net Core DLL? - If .Net Core can run on Windows, why can't you reference a .Net Core DLL in .Net Framework? 在 Azure DevOps .NET SDK 中使用 state 属性创建测试运行 - Create test run with state property in Azure DevOps .NET SDK .net 核心管道 azure devops - .net Core Pipeline in azure devops Azure Devops 管道 do.net 发布任务忽略项目设置 - Azure Devops Pipelines dotnet publish task ignores projects setting Azure DevOps YAML-dotnet核心CLI包可生成其他项目 - Azure DevOps YAML - dotnet core CLI pack builds additional projects
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM