OpenCover:无法为超过2个程序集运行coverage

时间:2015-08-27 04:40:16

标签: msbuild code-coverage opencover

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

public CommandBindingCollection CommandBindings { get; }

public YourViewModel()
{
//Create a command binding for the delete command
var deleteBinding = new CommandBinding(ApplicationCommands.Delete, DeleteExecuted, DeleteCanExecute);

//Register the binding to the class
CommandManager.RegisterClassCommandBinding(typeof(YourViewModel), DeleteBinding);

//Adds the binding to the CommandBindingCollection
CommandBindings.Add(deleteBinding);
}

认为问题将出现在我添加的第3个程序集中,所以再次单独运行它工作正常。以下是我使用的脚本:

    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.

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

1 个答案:

答案 0 :(得分:1)

尝试OpenCover

-targetdir选项

e.g。

<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" '/>