简体   繁体   中英

Getting an error running dotCover from Azure DevOps

I am trying to add a task to our build pipeline in Azure DevOps to calculate our code coverage using the dotCover commandline tool. However, I am getting the following error.

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.QualityTools.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.VisualStudio.TestTools.RunnerCommandline.Runner.Main(String[] args)

I have added a reference to the assembly Microsoft.VisualStudio.QualityTools.Common to our tests project and have set Copy Local to true so it gets copied into the bin folder.

Here is my command for executing dotCover (I have added dotCover and MSTEST to our project so we can run it from Azure DevOps ).

dotCover.exe analyse /TargetExecutable="Tools\MSTest\MSTest.exe" /TargetArguments="/testcontainer:\MyServices.Tests\bin\MyServices.Tests.dll" /Output="output.html" /ReportType="HTML"

UPDATE 09.10.2019

Here is the reference to the assembly in my.csproj. I have added a reference to v15 of the assembly.

<Reference Include="Microsoft.VisualStudio.QualityTools.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />

Getting an error running dotCover from Azure DevOps

Aswe know, the assembly Microsoft.VisualStudio.QualityTools.Common is part of Visual Studio.

When you add the assembly Microsoft.VisualStudio.QualityTools.Common to your tests project, you will get following in your project file .csproj :

  <ItemGroup>
    <Reference Include="Microsoft.VisualStudio.QualityTools.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
  </ItemGroup>

Even if you set Copy Local to true to get it copied into the bin folder. But the \bin folder is ignored by default by the .gitignore / .tfignore . When you build the project with Azure devops, it will still search the dll file from PublicAssemblies folder.

If we do not install Visual Studio 2015 on the build agent machine, we will not found it.

So, to resolve this issue, you need to install the Visual Studio 2015 on the build agent machine, then check if there is PublicAssemblies folder uder IDE, then check if the file Microsoft.VisualStudio.QualityTools.Common.dll exist or not.

Besides, if you do not want to install Visual Studio 2015 on the build agent machine, you could copy that Microsoft.VisualStudio.QualityTools.Common.dll from the PublicAssemblies folder to the project/solution folder, then add it as reference instead of from PublicAssemblies folder, then you will get following:

  <ItemGroup>
    <Reference Include="Microsoft.VisualStudio.QualityTools.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>.\Microsoft.VisualStudio.QualityTools.Common.dll</HintPath>
    </Reference>
  </ItemGroup>

Then, add this .dll file into the source control and submit it to the Azure repos.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM