nmbl Documentation
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage
Edit page

projectreferences - Project References

Overview

The projectreferences command analyzes a .slnx solution and reports the inbound and outbound project-to-project references for a specified target project. Inbound references are projects that depend on the target; outbound references are projects the target depends on. Paths are shown relative to the solution root.

The solution file is resolved automatically from the current directory when not supplied explicitly.

Syntax

nmbl projectreferences <ProjectFileOrFolderOrName> [--solution <SlnxFileOrDirectory>]

or using the positional convention:

nmbl projectreferences <SolutionPathOrDir> <ProjectFileOrFolderOrName>

Arguments

Named-parameter form

  • ProjectFileOrFolderOrName - Required. Identifies the target project. Accepted values:
    • Absolute path to a .csproj file
    • Relative path to a .csproj file (resolved from the solution directory)
    • Path to a directory containing exactly one .csproj file
    • A project name substring (matched against project file names in the solution)

Positional form

  • First argument — path to a .slnx file or a directory containing one.
  • Second argument — project identifier (same options as above).

Options

  • --solution, -s, --solutiondir <SlnxFileOrDirectory> - Explicit path to a .slnx file or a directory containing one. When omitted, the solution is resolved by searching upward from the current directory.

Output

Prints the resolved target project path, then two lists:


Target project:
  src/MyProject/MyProject.csproj

Inbound references (projects that reference this project):
  - src/Web/Web.csproj
  - tests/MyProject.Tests/MyProject.Tests.csproj
Total inbound: 2

Outbound references (projects this project references):
  - src/Core/Domain/Domain.csproj
Total outbound: 1

Exit Codes

  • 0 - Success.
  • 1 - Required arguments are missing, the solution or project cannot be resolved, or an unexpected error occurs.

Examples

Analyze a project by path

nmbl projectreferences src/MyLib/MyLib.csproj

Resolves the solution from the current directory and shows references for MyLib.csproj.

Analyze a project by folder

nmbl projectreferences src/MyLib

Finds the single .csproj in src/MyLib and analyzes it.

Specify the solution explicitly

nmbl projectreferences MyLib --solution C:/path/to/MySolution.slnx

Specify the solution as a directory

nmbl projectreferences MyLib --solution C:/path/to/solution/folder

Use the positional convention

nmbl projectreferences . src/MyLib

First argument is the solution directory (. searches the current directory for a .slnx file); second argument is the project folder.

Validate clean architecture

# Domain should have no outbound project references
nmbl projectreferences src/Domain/Domain.csproj

# Application should only reference Domain
nmbl projectreferences src/Application/Application.csproj

Find unused projects

# A project with no inbound references may be unused
nmbl projectreferences src/Legacy/OldLibrary/OldLibrary.csproj

Understanding the output

  • Inbound references — projects that reference the target. Changes to the target may affect these projects.
  • Outbound references — projects that the target depends on. Changes to those projects may affect the target.
  • deps - Generate visual dependency graphs
  • loc - Count lines of code