如何解决当我使用 x64 和 .NET5 时,如何在 Azure 管道中运行单元测试?
我有一个带有单元测试的小型演示项目。 使用 .net5 和 64 位/任何 cpu。
它们在我的 Azure 管道中运行时遇到问题。
我做了一个runsetting文件,但是不能指定5.0的net框架
我做了一个失败的单元测试,但它没有运行。
当我“调试”它时,我会在我的 azure 日志中得到这个..
2021-03-04T16:29:27.9652466Z /TestAdapterPath:"C:\DevOps\Agent 2_work\3\s" 2021-03-04T16:29:27.9652833Z /diag:"C:\DevOps\Agent 2_work_temp\c9f3dc90-7d06-11eb-9f3e-ab7c238ad233.txt" 2021-03-04T16:29:28.0475388Z 提供的设置文件不符合要求的格式。加载设置时出错。错误:无效的设置“runconfiguration”。为“TargetPlatform”指定的值“Anycpu”无效.. 2021-03-04T16:29:28.2479067Z ##[debug]从工具'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console收到退出代码1 。可执行程序' 2021-03-04T16:29:28.2484150Z ##[debug]STdio 流已关闭工具'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform\vstest.console 。可执行程序' 2021-03-04T16:29:28.2516774Z ##[警告]Vstest 失败并出现错误。检查日志是否有故障。可能有失败的测试。
我的 .runsettings 是:
<?xml version="1.0" encoding="utf-8"?>
<!-- File name extension must be .runsettings -->
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<runconfiguration>
<!-- Path relative to directory that contains .runsettings file-->
<ResultsDirectory>.\bin\TestResults</ResultsDirectory>
<!-- x86 or x64 -->
<!-- You can also change it from the Test menu;
choose "Processor Architecture for Anycpu Projects" -->
<TargetPlatform>Anycpu</TargetPlatform>
<!-- Framework35 | [Framework40] | Framework45 ... todo Framework50 er ikke suporteret-->
<TargetFrameworkVersion>Framework45</TargetFrameworkVersion>
<!-- true or false -->
<!-- Value that specifies the exit code when no tests are discovered -->
<TreatNoTestsAsError>false</TreatNoTestsAsError>
</runconfiguration>
</RunSettings>
ms Azure 是否不支持 .net50 进行单元测试,使用 vs 测试?
谢谢你的想法.. 肯尼斯
解决方法
我做了一个runsetting文件,但是不能指定5.0 net 框架
目标框架版本:
FrameworkCore10
用于 .NET Core 源,FrameworkUap10
用于
基于 UWP 的源代码,Framework45
用于 .NET Framework 4.5 和
更高,Framework40
用于 .NET Framework 4.0,Framework35
用于
.NET 框架 3.5。
此设置指定用于测试的单元测试框架的版本 发现并执行测试。它可以与版本不同 您在构建属性中指定的 .NET 平台的 单元测试项目。
如果您从 .runsettings 中省略 TargetFrameworkVersion
元素
文件,平台自动判断框架版本
基于构建的二进制文件。
对于错误:
加载设置时出错。错误:无效设置 '运行配置'。指定的值“AnyCPU”无效 '目标平台'
目标平台:x86、x64
根据the elements that the RunConfiguration
element can include,TargetPlatform
节点不提供AnyCPU
的值。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。