Skip to content

This npm package reads the NuGet dependencies of a .NET project, and generates a dependencies tree object.

License

Notifications You must be signed in to change notification settings

jfrog/nuget-deps-tree

Repository files navigation

Test

NuGet Dependency Tree

This npm package reads the NuGet dependencies of a .NET project, and generates a dependency tree. This package was developed by JFrog, and is used by the JFrog VS-Code Extension to generate the dependency tree for projects using NuGet dependencies. You may use this package for other purposes and applications as well, either by running via command line or by importing to your project.

Installation

npm install -g nuget-deps-tree

Usage

Prerequisites

nuget (or nuget.exe) should be available in $PATH.

Command Line

nuget-deps-tree [path to sln file], it will print dependencies in json.

or

nuget-deps-tree --text [path to sln file], it will print dependencies in plain text as below:

plaintext

Project Dependency

import { NugetDepsTree } from 'nuget-deps-tree';
let tree = NugetDepsTree.generate(pathToSlnFile);

Tree Structure

{
  "projects": [
    {
      "name": "First.Project",
      "dependencies": [
        {
          "id": "dependency.One",
          "version": "1.0.0",
          "dependencies": [
            {
              "id": "dependency.Child",
              "version": "4.0.0",
              "dependencies": []
            }
          ]
        },
        {
          "id": "dependency.Two",
          "version": "2.0.0",
          "dependencies": []
        }
      ]
    },
    {
      "name": "Second.Project",
      "dependencies": [
        {
          "id": "dependency.Three",
          "version": "3.0.0",
          "dependencies": []
        }
      ]
    }
  ]
}

Building and Testing the Sources

Preconditions

  • npm 10 or above
  • Node 18 or above

To build the plugin sources, please follow these steps:

  • Clone the code from git.
  • Install and pack the nuget-deps-tree dependency locally, by running the following npm commands:
npm i && npm pack

If you'd like run the nuget-deps-tree tests, run the following command:

npm t

Pull requests

We welcome pull requests from the community.

Guidelines

  • If the existing tests do not already cover your changes, please add tests.
  • Please run npm run format for formatting the code before submitting the pull request.