Search code examples
c#msbuildsonarqubexunitdotcover

xUnit dotCover msBuild error


I am trying to create an MSBuild build to output a dotCover.html report for upload to SonarQube. However - dotCover errors out even though all the Unit Test pass. I don't know where to go from here.

MsBuild File

  <ItemGroup>
    <TestAssemblies Include="**\bin\Release\*.tests.dll" />
  </ItemGroup>
  <PropertyGroup>
    <dlls>@(TestAssemblies, ' ')</dlls>
  </PropertyGroup>
  //Some other targets
  <Target Name="DotCover">
    <Exec Command='"%LOCALAPPDATA%\JetBrains\Installations\dotCover04\dotCover.exe" analyse /ReportType=HTML /Output="dotCover.html" /TargetWorkingDir=. /TargetExecutable:"packages\xunit.runner.console.2.1.0\tools\xunit.console.exe" /TargetArguments="$(dlls) -noshadow" /LogFile' />
  </Target>

Error in the dotCover LogFile

15:17:29.682 |I| IteratorsProcessor | Can't find matching method for iterator class Xunit.Sdk.XunitTestAssemblyRunner+d__14 Extracted containing method name: RunTestCollectionsAsync Candidates number: 0 Parent type methods: .ctor; Dispose; GetTestFrameworkDisplayName; GetTestFrameworkEnvironment; SetupSyncContext; Initialize; AfterTestAssemblyStartingAsync; BeforeTestAssemblyFinishedAsync; RunTestCollectionsAsync; RunTestCollectionAsync; SetSynchronizationContext; <>n__0 15:17:29.703 |I| IteratorsProcessor | Can't find matching method for iterator class Xunit.Assert+d__56`1 Extracted containing method name: ThrowsAsync Candidates number: 0 Parent type methods: .ctor; Equals; ReferenceEquals; False; False; False; False; True; True; True; True; All; Collection; Contains; Contains; Contains; DoesNotContain; DoesNotContain; DoesNotContain; Empty; Equal; Equal; NotEmpty; NotEqual; NotEqual; Single; Single; Single; Single; GetComparer; GetEqualityComparer; Equal; Equal; Equal; Equal; StrictEqual; NotEqual; NotEqual; NotEqual; NotEqual; NotStrictEqual; Throws; Throws; Throws; ThrowsAsync; ThrowsAny; ThrowsAny; ThrowsAnyAsync; Throws; Throws; ThrowsAsync; Throws; ThrowsAny; Throws; Throws; Throws; ThrowsAsync; GuardArgumentNotNull; RecordException; RecordException; RecordException; RecordExceptionAsync; NotSame; Same; NotNull; Null; PropertyChanged; InRange; InRange; NotInRange; NotInRange; ProperSubset; ProperSuperset; Subset; Superset; Contains; Contains; DoesNotContain; DoesNotContain; StartsWith; StartsWith; EndsWith; EndsWith; Matches; Matches; DoesNotMatch; DoesNotMatch; Equal; Equal; IsLineEnding; IsWhiteSpace; SkipLineEnding; SkipWhitespace; IsAssignableFrom; IsAssignableFrom; IsNotType; IsNotType; IsType; IsType

Any help would be very much appreciated. Thank you.


Solution

  • DotCover is unable to process information against the assemblies without having PDBs available for use. You can set the PDBs to be utilized by either adding <DebugType>pdbonly</DebugType> under the configuration being used for your builds, or adding the /debug:pdbonly switch to the compiler line for your project. You can set these through the project's properties on the build panel, through the advanced options section, or by manually editing the csproj. If having the PDBs isn't optimal you may be able to set a post condition to run after dotcover to clean them out.