Meziantou.Framework.DependencyScanning 3.0.17

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Meziantou.Framework.DependencyScanning --version 3.0.17
                    
NuGet\Install-Package Meziantou.Framework.DependencyScanning -Version 3.0.17
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Meziantou.Framework.DependencyScanning" Version="3.0.17" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Meziantou.Framework.DependencyScanning" Version="3.0.17" />
                    
Directory.Packages.props
<PackageReference Include="Meziantou.Framework.DependencyScanning" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Meziantou.Framework.DependencyScanning --version 3.0.17
                    
#r "nuget: Meziantou.Framework.DependencyScanning, 3.0.17"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Meziantou.Framework.DependencyScanning@3.0.17
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Meziantou.Framework.DependencyScanning&version=3.0.17
                    
Install as a Cake Addin
#tool nuget:?package=Meziantou.Framework.DependencyScanning&version=3.0.17
                    
Install as a Cake Tool

Meziantou.Framework.DependencyScanning

A .NET library for scanning source code directories and files to discover and manage project dependencies across multiple package ecosystems and configuration formats.

Features

  • Multi-format Support: Scan dependencies from various project files and configuration formats
  • Multiple Package Ecosystems: NuGet, npm, PyPI, Docker, Swift packages, Helm Charts, and more
  • Parallel Scanning: High-performance parallel file scanning with configurable degree of parallelism
  • Dependency Updates: Locate and update dependency versions programmatically
  • Customizable Scanning: Filter by file patterns, dependency types, and custom predicates

Supported Dependency Types

The library can detect the following dependency types:

  • NuGet - .NET packages from NuGet.org
  • Npm - JavaScript packages from npmjs.com
  • PyPi - Python packages from PyPI
  • DockerImage - Docker container images
  • GitReference - Git submodules and references
  • DotNetSdk - .NET SDK versions
  • DotNetTargetFramework - .NET target frameworks
  • GitHubActions - GitHub Actions workflows and reusable workflows
  • AzureDevOpsVMPool - Azure DevOps VM pool images
  • AzureDevOpsTask - Azure DevOps pipeline tasks
  • AzureDevOpsTemplate - Azure DevOps pipeline templates
  • HelmChart - Helm chart dependencies
  • RenovateConfiguration - Renovate configuration extends
  • SwiftPackage - Swift Package Manager dependencies
  • MSBuildProjectReference - MSBuild project references
  • DotNetAssemblyReference - .NET assembly file references
  • RubyGem - Ruby gem packages

Scanner Notes

  • Docker images (Dockerfile FROM and COPY --from, GitHub Actions container, services and docker:// references, Azure Pipelines containers): the tag is the part after the last : that follows the last /, so localhost:5000/image:1.0 is reported as localhost:5000/image version 1.0. An image pinned by digest (image@sha256:... or image:tag@sha256:...) is reported with the digest as its version. This version is not updatable, and the digest and tag are available in Dependency.Metadata under the digest and tag keys. In a Dockerfile, only references with a tag or a digest are reported, so build stage names are not mistaken for images.
  • Variables: names or versions that contain a variable reference, such as FROM node:${NODE_VERSION}, are reported with a location that is not updatable.
  • YAML files: a value is only updatable when its text in the file is exactly its value (plain scalars, and single-line quoted scalars without escape sequences). Block scalars (|, >), escaped or multi-line values are reported with a location that is not updatable. A value referenced through an alias (*name) is reported once.
  • GitHub Actions: workflows in .github/workflows and action metadata files (action.yml, action.yaml) anywhere in the repository are scanned. Local actions and reusable workflows (uses: ./...) are not reported.
  • Azure Pipelines: templates referenced from steps, jobs, stages and extends, deployment job lifecycle hooks, and git, github, githubenterprise and bitbucket repository resources are reported. A job container that names a container resource is not reported again.
  • Helm charts: the dependency name is the chart name. The repository and alias values are available in Dependency.Metadata under the repository and alias keys.
  • npm: protocol and path specifiers (workspace:, file:, link:, git URLs, github:, tarball URLs, owner/repo shorthands, ...) are reported with a version location that is not updatable. An alias ("name": "npm:package@1.0.0") is reported as the aliased package, with the alias name in Dependency.Metadata under the alias key.
  • Python: *requirements*.txt files and .txt files in a requirements directory are scanned. Only exact pins (==) are reported.
  • Renovate: .json5 files are read as JSON with comments and trailing commas. JSON5-only syntax, such as unquoted property names or single-quoted strings, is not supported.

Usage

Scan a Directory

using Meziantou.Framework.DependencyScanning;

// Scan with default options
var dependencies = await DependencyScanner.ScanDirectoryAsync(
    "C:\\MyProject",
    options: null,
    cancellationToken);

foreach (var dependency in dependencies)
{
    Console.WriteLine($"{dependency.Type}: {dependency.Name}@{dependency.Version}");
}

Scan with Custom Options

var options = new ScannerOptions
{
    // Number of parallel scanning tasks (default: 16)
    DegreeOfParallelism = 8,

    // Recurse into subdirectories (default: true)
    RecurseSubdirectories = true,

    // Filter files to scan
    ShouldScanFilePredicate = (directory, fileName) =>
    {
        return !fileName.StartsWith(".");
    },

    // Filter directories to recurse into
    ShouldRecursePredicate = (directory, name) =>
    {
        return name != "node_modules" && name != "bin";
    }
};

var dependencies = await DependencyScanner.ScanDirectoryAsync(
    @"C:\MyProject",
    options,
    cancellationToken);

Filter by Dependency Type

var options = new ScannerOptions
{
    // Only scan for specific dependency types
    IncludedDependencyTypes = [DependencyType.NuGet, DependencyType.Npm],
};

// Or exclude specific types
var options2 = new ScannerOptions
{
    ExcludedDependencyTypes = [DependencyType.DockerImage],
};

Stream Dependencies as They're Found

await DependencyScanner.ScanDirectoryAsync(
    "C:\\MyProject",
    options: null,
    onDependencyFound: dependency =>
    {
        Console.WriteLine($"Found: {dependency.Name}@{dependency.Version}");
    },
    cancellationToken);

Scan Individual Files

// Scan a single file
var dependencies = await DependencyScanner.ScanFileAsync(
    rootDirectory: "C:\\MyProject",
    filePath: "C:\\MyProject\\package.json",
    options: null,
    cancellationToken);

// Scan multiple specific files
var filePaths = new[]
{
    "C:\\MyProject\\package.json",
    "C:\\MyProject\\MyProject.csproj"
};

var dependencies = await DependencyScanner.ScanFilesAsync(
    rootDirectory: "C:\\MyProject",
    filePaths,
    options: null,
    cancellationToken);

Update Dependency Versions

var dependencies = await DependencyScanner.ScanDirectoryAsync(
    "C:\\MyProject",
    options: null,
    cancellationToken);

// Update all NuGet packages to version 2.0.0
foreach (var dependency in dependencies.Where(d => d.Type == DependencyType.NuGet))
{
    if (dependency.VersionLocation?.IsUpdatable == true)
    {
        await dependency.UpdateVersionAsync("2.0.0", cancellationToken);
    }
}

Custom Regex Scanner

For custom file formats, you can use the RegexScanner:

var options = new ScannerOptions
{
    Scanners =
    [
        new RegexScanner
        {
            FilePatterns = [Glob.Parse("**/*.custom", GlobDialect.Standard, GlobOptions.IgnoreCase)],
            DependencyType = DependencyType.DockerImage,
            Regex = new Regex(@"image:\s*(?<name>[a-z/]+)(:(?<version>[0-9.]+))?", RegexOptions.ExplicitCapture, TimeSpan.FromSeconds(10))
        }
    ]
};

var dependencies = await DependencyScanner.ScanDirectoryAsync(
    "C:\\MyProject",
    options,
    cancellationToken);

FilePatterns are matched against the path of the file relative to the scanned root directory, for instance build/*.yml or **/*.custom.

The regex pattern must include named groups:

  • name - The dependency name (required)
  • version - The dependency version (optional)
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.21 37 10/14/2026
3.0.20 94 10/11/2026
3.0.19 153 9/30/2026
3.0.18 97 9/27/2026
3.0.17 158 9/20/2026
3.0.16 133 9/15/2026
3.0.15 103 9/13/2026
3.0.14 122 9/11/2026
3.0.13 143 9/8/2026
3.0.12 124 9/6/2026
3.0.11 170 9/3/2026
3.0.10 104 9/3/2026
3.0.9 191 8/30/2026
3.0.8 116 8/29/2026
3.0.7 156 8/23/2026
3.0.6 219 8/16/2026
3.0.5 261 8/9/2026
3.0.4 229 7/17/2026
3.0.3 126 7/12/2026
3.0.2 201 7/7/2026
Loading failed