Search code examples
c#tfsdotcover

How can one add the dotcover exclude file settings to the TFS?


I'm trying to add the "exclude file" settings (for jetbrains-dotcover) that I make to the TFS in order to avoid co programmers having to set the same settings manually.

After trying around and searching I didn't find any info there and thus my question is: Is this possible to do? And if so how?


Solution

  • I am presuming that you are running dotCover from the command line in TFS. With reference to the documentation on running DotCover from the command line you need to add a parameter to your call to exclude the assemblies:

    /Filters=ARG : (Optional) Specify coverage filters using following syntax: +:module=;class=;function=; Use -:myassembly to exclude an assembly from code coverage. Asterisk wildcard () is supported here

    If you have a dotCover xml file for your coverage settings you can put the exclusion into it. See the same documentation for editing the xml. I imagine the bit you need to add would look something like this:

    <Filters>
      <ExcludeFilters>
        <FilterEntry>
          <ModuleMask>AssemblyToExclude.dll</ModuleMask>
          <ModuleMask>*Tests*</ModuleMask> <!--This is an example to exclude all assemblies with Tests in their name-->
        </FilterEntry>
      </ExcludeFilters>
    </Filters>
    

    There is some general info in the documentation on how to set up running from the command line.

    *Proviso: I haven't tried what I have suggested, I am merely projecting from my own DotCover/TeamCIty TFS experience. More information may provide a more accurate answer.

    Update:
    If you are using dotCover as per @Thomas comment, then you can edit the filters for you machine by running dotCover and selecting File=>Edit Coverage Filters... If you add a filter there it will also apply to any coverage run from Visual Studio. For example adding an assembly *Test* exclude filter will stop any assembly with the word Test in from being included in the reports:

    Coverage Filters

    I would think that your team would need to have the same exclusion filters setup on all their machines.

    Update2:
    I found where the per solution filter settings are stored. They are in your DotSettings file next to your sln (e.g. MyProject.sln has MyProject.sln.DotSettings). In order to get the exclusion into this file you should in Visual studio with your solution open go to DotCover->Edit Coverage Filters and Add a Filter for the current solution.

    Add solution Filter

    This yields the following info in your DotSettings file:

    <s:String x:Key="/Default/FilterSettingsManager/CoverageFilterXml/@EntryValue">&lt;data&gt;&lt;IncludeFilters /&gt;&lt;ExcludeFilters&gt;&lt;Filter ModuleMask="*Maths*" ModuleVersionMask="*" ClassMask="*" FunctionMask="*" IsEnabled="True" /&gt;&lt;/ExcludeFilters&gt;&lt;/data&gt;</s:String>
    

    If you commit the DotSettings file to TFS your team will get the exclusions. See the docs about sharing your settings here and the docs and about setting them up here.