Skip to content

timo-reymann/DotNet.GitlabCodeQualityBuildLogger

Repository files navigation

DotNet.GitlabCodeQualityBuildLogger

GitHub Release NuGet Version LICENSE GitHub Actions Renovate Quality Gate Status Maintainability Rating Security Rating


An MSBuild logger that outputs build warnings and errors in GitLab Code Quality report format.

Features

  • Captures build errors and warnings during dotnet build
  • Outputs JSON in GitLab Code Quality format
  • Automatic severity mapping:
    • Build errors → critical
    • CS* (compiler warnings) → major
    • CA2*/CA5* (security rules) → major
    • CA* (other code analysis) → minor
    • IDE*/SA* (style suggestions) → info
    • Other warnings → minor
  • Generates stable fingerprints for issue tracking

Requirements

  • .NET SDK 6.0 or later (for running the tool)
  • MSBuild-based project

Installation

Project-level (recommended)

dotnet new tool-manifest # if you don't have a tool manifest yet
dotnet tool install GitlabCodeQualityBuildLogger.Tool

Global

dotnet tool install -g GitlabCodeQualityBuildLogger.Tool

Usage

Project-level (recommended)

dotnet build -logger:"$(dotnet tool run gitlab-code-quality-logger);gl-code-quality-report.json"

Global

dotnet build -logger:"$(gitlab-code-quality-logger);gl-code-quality-report.json"

GitLab CI Example

build:
  stage: build
  script:
    - dotnet tool restore
    - dotnet build -logger:"$(gitlab-code-quality-logger);gl-code-quality-report.json"
  artifacts:
    reports:
      codequality: gl-code-quality-report.json

Output Format

The logger produces JSON compatible with GitLab's Code Quality report format:

[
  {
    "description": "CS0168: The variable 'x' is declared but never used",
    "check_name": "CS0168",
    "fingerprint": "A1B2C3D4E5F6...",
    "severity": "major",
    "location": {
      "path": "src/MyClass.cs",
      "lines": {
        "begin": 42
      }
    }
  }
]

Motivation

GitLab's Code Quality feature provides a great way to track code issues directly in merge requests. However, there was no simple way to integrate .NET build warnings and errors into this workflow. This logger bridges that gap by converting MSBuild output into GitLab's expected format.

Contributing

I love your input! I want to make contributing to this project as easy and transparent as possible, whether it's:

  • Reporting a bug
  • Discussing the current state of the configuration
  • Submitting a fix
  • Proposing new features
  • Becoming a maintainer

To get started please read the Contribution Guidelines.

Development

Requirements

Build

dotnet build

Test

dotnet test

Project Structure

src/
├── DotNet.GitlabCodeQualityBuildLogger/       # Core logger library (netstandard2.1)
└── DotNet.GitlabCodeQualityBuildLogger.Tool/  # CLI tool wrapper (net9.0)
tests/
└── DotNet.GitlabCodeQualityBuildLogger.Tests/ # xUnit tests

About

Convert dotnet build output to GitLab Code Quality reports for MR integration

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages