Hamburger Cross Icon
.NET Collector - Lunar Collector

.NET Collector

Collector Beta LanguagesBuild

Analyze .NET projects to collect project structure, target frameworks, NuGet dependencies, and test project identification. Supports C#, F#, and VB.NET with SDK-style and legacy projects.

Add dotnet to your lunar-config.yml:
uses: github://earthly/lunar-lib/collectors/dotnet@v1.0.0

What This Integration Collects

This integration includes 3 collectors that gather metadata from your systems.

Collector code

project

Detects .NET project structure including project files (.csproj, .fsproj, .vbproj), solution files (.sln), SDK configuration (global.json), MSBuild properties (Directory.Build.props), target frameworks, project types, and SDK versions. Writes project metadata to .lang.dotnet.

.net project csharp fsharp dotnet csproj sln
Book a demo
Collector code

dependencies

Extracts NuGet dependencies from project files, including direct dependencies, project references, and dependency locking status (packages.lock.json). Writes dependency data to .lang.dotnet.dependencies.

nuget dependencies packages project references supply chain
Book a demo
Collector ci-before-command

cicd

Records every dotnet command executed in CI pipelines along with the .NET SDK version. Writes command strings and version info to .lang.dotnet.cicd for audit trails and build reproducibility analysis.

dotnet ci dotnet version ci commands build tracking deployment tracking
Book a demo

How Collectors Fit into Lunar

Lunar watches your code and CI/CD systems to collect SDLC data from config files, test results, IaC, deployment configurations, security scans, and more.

Collectors are the automatic data-gathering layer. They extract structured metadata from your repositories and pipelines, feeding it into Lunar's centralized database where guardrails evaluate it to enforce your engineering standards.

Learn How Lunar Works
1
Collectors Gather Data This Integration
Triggered by code changes or CI pipelines, collectors extract metadata from config files, tool outputs, test results, and scans
2
{ } Centralized as JSON
All data merged into each component's unified metadata document
3
Guardrails Enforce Standards
Real-time feedback in PRs and AI workflows

Example Collected Data

This collector writes structured metadata to the Component JSON. Here's an example of the data it produces:

{ } component.json Component JSON
{
  "lang": {
    "dotnet": {
      "sdk_version": "8.0.100",
      "target_frameworks": ["net8.0"],
      "project_files": [
        {
          "path": "MyApp/MyApp.csproj",
          "type": "csharp",
          "output_type": "Exe",
          "target_framework": "net8.0"
        }
      ],
      "solution_files": ["MyApp.sln"],
      "global_json_exists": true,
      "directory_build_props_exists": false,
      "packages_lock_exists": true,
      "test_projects": [
        {
          "path": "MyApp.Tests/MyApp.Tests.csproj",
          "type": "csharp",
          "test_framework": "xunit"
        }
      ],
      "source": { "tool": "dotnet", "integration": "code" },
      "dependencies": {
        "direct": [
          {
            "name": "Microsoft.Extensions.Hosting",
            "version": "8.0.0",
            "type": "package"
          }
        ],
        "project_references": [
          {
            "path": "MyLibrary/MyLibrary.csproj"
          }
        ],
        "source": { "tool": "dotnet", "integration": "code" }
      },
      "cicd": {
        "cmds": [
          {"cmd": "dotnet restore", "version": "8.0.100"},
          {"cmd": "dotnet build --configuration Release", "version": "8.0.100"},
          {"cmd": "dotnet test --no-build", "version": "8.0.100"}
        ],
        "source": {"tool": "dotnet", "integration": "ci"}
      }
    }
  }
}

Documentation

View on GitHub

.NET Collector

Collects .NET/C# project information, dependencies, and test project detection.

Overview

This collector gathers metadata about .NET projects including project structure detection, target frameworks, NuGet dependencies, project references, and test project identification. It supports C#, F#, and VB.NET projects with both SDK-style and legacy project formats. Code hooks analyze project files statically to extract build and dependency information.

Collected Data

This collector writes to the following Component JSON paths:

Path Type Description
.lang.dotnet object .NET project metadata (SDK version, frameworks, project files, test projects)
.lang.dotnet.dependencies object NuGet packages and project references from project files
.lang.dotnet.cicd object CI/CD command tracking with SDK version

Collectors

This plugin provides the following collectors (use include to select a subset):

Collector Hook Type Description
project code Detects .NET project structure, target frameworks, SDK versions, test projects
dependencies code Extracts NuGet dependencies and project references from project files
cicd ci-before-command Tracks dotnet commands in CI with SDK version

Installation

Add to your lunar-config.yml:

collectors:
  - uses: github://earthly/lunar-lib/collectors/dotnet@v1.0.0
    on: ["domain:your-domain"]  # replace with your own domain or tags
    # include: [project, dependencies]  # Only include specific subcollectors

Open Source

This collector is open source and available on GitHub. Contribute improvements, report issues, or fork it for your own use.

View Repository

Ready to Automate Your Standards?

See how Lunar can turn your engineering wiki, compliance docs, or postmortem action items into automated guardrails with our 100+ built-in guardrails.

Works with any process
check Infrastructure conventions
check Post-mortem action items
check Security & compliance policies
check Testing & quality requirements
Automate Now
Turn any process doc into guardrails
Book a Demo