Appveyor 找不到测试覆盖率

Appveyor cannot find test coverage

我在 github 上有一个与 Appveyor 集成的小项目 (.netstandard 1.0 + net45)。 我使用 xunit 进行单元测试,使用 opencover 进行测试覆盖。 我无法让 Appveyor 提交测试结果,这是输出:

Committing... No results, this could be for a number of reasons. The most common reasons are: 1) missing PDBs for the assemblies that match the filter please review the output file and refer to the Usage guide (Usage.rtf) about filters. 2) the profiler may not be registered correctly, please refer to the Usage guide and the -register switch.

这是我的脚本:

- .\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe \ -target:"c:\Program Files\dotnet\dotnet.exe" \ -targetargs:"test -f netcoreapp1.1 -c %CONFIGURATION% Giver.Tests/Giver.Tests.csproj" \ -mergeoutput \ -hideskipped:File \ -output:opencoverCoverage.xml \ -oldStyle \ -filter:"+[Giver*]* -[Giver.*Tests*]*" \ -searchdirs:Giver.Tests/bin/%CONFIGURATION%/netcoreapp1.1 \ -register:user

所有项目的调试类型已满。

我可能尝试了 OpenCover.Console 个参数的大部分组合。

相同的脚本在我的机器上运行(替换 %CONFIGURATION% 后)。

是的,这完全是我的错误。

如果您使用 项目属性 页面将 DebugType 更改为 Full(Visual Studio), 当心,它会添加这样的条件:

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

我正在为 Appveyor 构建使用 Release 配置,因此不会满足此条件,并且会生成可移植的 .pdb(opencover 仅适用于 Full .pdb)。

删除这个条件后,一切正常