Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: How to get report generator reading arguments from .netconfig #400

Closed
dcs3spp opened this issue Dec 15, 2020 · 6 comments
Closed
Labels

Comments

@dcs3spp
Copy link

dcs3spp commented Dec 15, 2020

dotnet reportgenerator does not appear to be reading arguments from .netconfig in current working directory. Instead it displays usage information in the console. What am I doing wrong?

Name of .netconfig file = .netconfig

Contents of .netconfig file

[ReportGenerator]
	reports = "/Users/me/Development/Dotnet/CamFrontEnd/Tests/**/coverage.cobertura.xml"
	targetdir = "/Users/me/Development/Dotnet/CamFrontEnd/CoverageReports"
	reporttypes = HtmlSummary
	assemblyfilters = -Minio;-WebApp.Testing.Utils;-WebApp.Testing.Mocks;-xunit.*;-WebApp.Blazor.UnitTests;-Bunit.*;-Humanizer
	classfilters = -Cyotek.Collections.Generic.*

Output from dotnet reportgenerator

dotnet reportgenerator


2020-12-15T12:41:16: Arguments

ReportGenerator 4.8.1.0

Parameters:
    ["]-reports:<report>[;<report>][;<report>]["]
    ["]-targetdir:<target directory>["]
    [["]-reporttypes:<Badges|Clover|Cobertura|...>[;<Badges|Clover|Cobertura|...>]["]]"
    [["]-sourcedirs:<directory>[;<directory>][;<directory>]["]]
    [["]-historydir:<history directory>["]]
    [["]-plugins:<plugin>[;<plugin>][;<plugin>]["]]
    [["]-assemblyfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
    [["]-classfilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
    [["]-filefilters:<(+|-)filter>[;<(+|-)filter>][;<(+|-)filter>]["]]
    [["]-verbosity:<Verbose|Info|Warning|Error|Off>["]]
    [["]-title:<title>["]]
    [["]-tag:<tag>["]]

Explanations:
    Reports:            The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
    Target directory:   The directory where the generated report should be saved.
    Report types:       The output formats and scope (separated by semicolon).
                        Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
    Source directories: Optional directories which contain the corresponding source code (separated by semicolon).
                        The source directories are used if coverage report contains classes without path information.
                        Globbing is not supported.
    History directory:  Optional directory for storing persistent coverage information.
                        Can be used in future reports to show coverage evolution.
    Plugins:            Optional plugin files for custom reports or custom history storage (separated by semicolon).
    Assembly filters:   Optional list of assemblies that should be included or excluded in the report.
    Class filters:      Optional list of classes that should be included or excluded in the report.
    File filters:       Optional list of files that should be included or excluded in the report.
                        Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
    Verbosity:          The verbosity level of the log messages.
                        Values: Verbose, Info, Warning, Error, Off
    Title:              Optional title.
    Tag:                Optional tag or build version.

Default values:
   -reporttypes:Html
   -assemblyfilters:+*
   -classfilters:+*
   -filefilters:+*
   -verbosity:Info

Examples:
   "-reports:coverage.xml" "-targetdir:C:\report"
   "-reports:target\*\*.xml" "-targetdir:C:\report" -reporttypes:Latex;HtmlSummary -title:IntegrationTest -tag:v1.4.5
   "-reports:coverage1.xml;coverage2.xml" "-targetdir:report" "-sourcedirs:C:\MyProject" -plugins:CustomReports.dll
   "-reports:coverage.xml" "-targetdir:C:\report" "-assemblyfilters:+Included;-Excluded.*"
@danielpalme
Copy link
Owner

You are not doing anything wrong.
If you don't pass any parameters to ReportGenerator, the help shows up.

I have to fix that behavior.

@dcs3spp
Copy link
Author

dcs3spp commented Dec 15, 2020

Hi @danielpalme,

So does that mean cannot use .netconfig feature yet?

@danielpalme
Copy link
Owner

It should work, if you supply at least two dummy command line arguments.
But I will fix this in the evening.

@dcs3spp
Copy link
Author

dcs3spp commented Dec 15, 2020

Ok, thanks @danielpalme. I tried reverting to MS Build. Not as familiar with msbuild. Could not get it working, it gives output that ReportGenerator task was not found. I will wait and use .netconfig fix 👍

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk" DefaultTargets="TestCoverage">
    <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    </PropertyGroup>

    <!-- Imported MSBuild tasks -->
    <ItemGroup>
        <PackageReference Include="ReportGenerator" Version="4.8.1.0" />
        <CoverageReport Include="$(MSBuildProjectDirectory)/../CoverageReports" />
    </ItemGroup>

    <!-- Remove existing coverage, for now do not store history -->
    <Target Name="CleanCoverage" BeforeTargets="TestCoverage">
        <RemoveDir Directories="@(CoverageReport)" />
    </Target>

    <!-- Test Coverage -->
    <Target Name="TestCoverage">
        <ItemGroup>
            <CoverageFiles Include="**/coverage.cobertura.xml" />
        </ItemGroup>

        <ReportGenerator
            ProjectDirectory="$(MSBuildProjectDirectory)"
            ReportFiles="@(CoverageFiles)"
            TargetDirectory="$(MSBuildProjectDirectory)/../CoverageReports"
            ReportTypes="Html"
            AssemblyFilters="-Minio;-WebApp.Testing.Utils;-WebApp.Testing.Mocks;-xunit.*;-WebApp.Blazor.UnitTests;-Bunit.*;-Humanizer"
            ClassFilters="-Cyotek.Collections.Generic.*"
        />
    </Target>
</Project>

Update, got this working, I had updated project filename and task names and forgot to issue a rebuild

@danielpalme
Copy link
Owner

Great that it works for you.
I fixed the problem anyway. Release 4.8.2 should be available soon.

@dcs3spp
Copy link
Author

dcs3spp commented Dec 16, 2020

Thanks @danielpalme, appreciated :) will give it a try when available

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants