Msbuild OpenCover:无法运行超过2个程序集的覆盖率

Msbuild OpenCover:无法运行超过2个程序集的覆盖率,msbuild,code-coverage,opencover,Msbuild,Code Coverage,Opencover,我正在尝试将OpenCover与XUnit和MSBuild一起用于我们的项目,它可以与一个或两个程序集配合使用。但当程序集的数量超过2时,将抛出以下错误: EXEC : error : unknown command line option: MyProj.UnitTest.dll [C:\CMR\Source\trunk\Build\Script\CMR.msbuild] Committing... No results, this could be for a

我正在尝试将OpenCover与XUnit和MSBuild一起用于我们的项目,它可以与一个或两个程序集配合使用。但当程序集的数量超过2时,将抛出以下错误:

    EXEC : error : unknown command line option: MyProj.UnitTest.dll
    [C:\CMR\Source\trunk\Build\Script\CMR.msbuild]
    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.
我以为问题出在我添加的第三个程序集上,所以再次单独运行,效果很好。下面是我使用的脚本:

<Exec Command='$(OpenCoverPath)\OpenCover.Console.exe "-target: $(XUnitPath)\xunit.console.exe" "-targetargs:C:\MyPath\UnitTest1.dll C:\MyPath\UnitTest2.dll C:\MyPath\UnitTest3.dll /noshadow" "-output:c:\OpenCoverReport\coverage.xml"'/>


这是我的假设,为了在这里发布,我把dll的路径设置为C:\MyPath\UnitTest.dll,但实际上路径太大了,有多个程序集具有巨大的路径。这与此错误有关吗?

请尝试的
-targetdir
选项

e、 g



我不能那样做。因为我的所有测试程序集都不在同一目录中。这是否意味着如果我必须运行多个程序集,我必须将所有测试程序集都放在同一目录中?这样-是-或者您可以单独运行每个程序集,并使用
-mergeoutput
合并结果-我建议您阅读指南了解运行每个程序集的问题另外,当我引入新的测试项目时,我必须不断更新构建脚本。我看了《使用指南》,它在语法方面有帮助,但在通过单个execuild运行多个程序集时没有帮助。因为您使用的是MSBuild,所以可以自动生成文件集合(一个项目组),然后使用该集合为每个程序集运行OpenCover。
<Exec Command='$(OpenCoverPath)\OpenCover.Console.exe -targetdir:"C:\MyPath" "-target: $(XUnitPath)\xunit.console.exe" "-targetargs:UnitTest1.dll UnitTest2.dll UnitTest3.dll /noshadow" "-output:c:\OpenCoverReport\coverage.xml" '/>