NDepend.Console.exe command line options

NDepend can analyze .NET code and produce report through $NDependInstallDir$\NDepend.Console.exe and $NDependInstallDir$\net10.0\NDepend.Console.MultiOS.dll. Let's first compare these two executables.

$NDependInstallDir$\NDepend.Console.exe requires .NET 4.7.2 or upper to run on Windows.

$NDependInstallDir$\net10.0\NDepend.Console.MultiOS.dll requires .NET 10.0 to run on Windows, Linux or macOS.

All NDepend.Console.exe switches explained in the present documentation are also supported by NDepend.Console.MultiOS.dll.

You can refer to Getting Started with NDepend on Linux and macOS if you want to use NDepend.Console.MultiOS.dll on Linux or macOS.

Analyze and Build Report with NDepend.Console

Notice that NDepend.Console.exe returns a non-zero exit code when at least one Quality Gate fails. This exit code can be used to eventually stop your build process in such situation.
To only run the rules and the quality gates without building a report, typically from an AI coding agent, see the switches /QualityGateCheck and /IssueCheck.

Mandatory

  • The path to the input .ndproj NDepend project file.

    It must be specified as the first argument. If you need to specify a path that contains a space character use double quotes ".. ..". The specified path can be either an absolute path (with drive letter C:\ or UNC \\Server\Share format), a path relative to the current directory (obtained with System.Environment.CurrentDirectory), or a file name in the current directory.

Following arguments are OPTIONAL and can be provided in any order. Any file or directory path specified in optional arguments can be:

  • Absolute : with drive letter C:\ or UNC \\Server\Share format.
  • Relative : to the ", productName, @" project file location.
  • Prefixed with an environment variable with the syntax %ENVVAR%\Dir\
  • Prefixed with a path variable with the syntax $(Variable)\Dir

Optional

  • /ViewReport: to view the HTML report
  • /Silent: to disable output and eventual calls to Console.Read() on console
  • /HideConsole: to hide the console window
  • /Concurrent: to parralelize analysis execution
  • /LogTrendMetrics: to force log trend metrics
  • /TrendStoreDir: to override the trend store directory specified in the NDepend project file
  • /PersistHistoricAnalysisResult: to force persist historic analysis result
  • /DontPersistHistoricAnalysisResult: to force not persist historic analysis result
  • /ForceReturnZeroExitCode: to force return a zero exit code even when one or many quality gate(s) fail
  • /HistoricAnalysisResultsDir: to override the historic analysis results directory specified in the NDepend project file.
  • /OutDir dir : to override the output directory specified in the NDepend project file.

    VisualNDepend.exe won't work on the machine where you used NDepend.Console.exe with the option /OutDir because VisualNDepend.exe is not aware of the output dir specified and will try to use the output dir specified in your NDepend project file.

  • /AnalysisResultId id: to assign an identifier to the analysis result
  • /GitHubPAT pat: to provide a GitHub PAT (Personal Access Token).

    Such PAT is used in case some artifacts (like a baseline analysis result) are required during analysis and must be loaded from GitHub. Such PAT overrides the PAT registered on the machine (if any).

  • /XslForReport xlsFilePath: to provide your own Xsl file used to build report
  • /KeepXmlFilesUsedToBuildReport: to keep xml files used to build report
  • /InDirs dir1 [dir2 ...]: to override input directories specified in the NDepend project file.

    This option is used to customize the location(s) where assemblies to analyze (application assemblies and third-party assemblies) can be found.

    Only assemblies resolved in dirs are concerned, not assemblies resolved from a Visual Studio solution.

    The search in dirs is not recursive, it doesn't look into child dirs.

    Directly after the option /InDirs, the option /KeepProjectInDirs can be used to avoid ignoring directories specified in the NDepend project file.

  • /CoverageFiles file1 [file2 ...]: to override input coverage files specified in the NDepend project file.

    Directly after the option /CoverageFiles, the option /KeepProjectCoverageFiles can be used to avoid ignoring coverage files specified in the NDepend project file.

  • /CoverageDir dir: to override the directory that contains coverage files specified in the project file
  • /CoverageExclusionFile file: to override the .runsettings file specified in the project file. NDepend gathers coverage exclusion data from such file.
  • /RuleFiles file1 [file2 ...]: to override input rule files specified in the NDepend project file.

    Directly after the option /RuleFiles, the option /KeepProjectRuleFiles can be used to avoid ignoring rule files specified in the NDepend project file.

  • /PathVariables Name1 Value1 [Name2 Value2 ...]: to override the values of one or several NDepend project path variables, or create new path variables.
  • /AnalysisResultToCompareWith: to provide a previous analysis result to compare with.

    Analysis results are stored in files with file name prefix NDependAnalysisResult_ and with extension .ndar. These files can be found under the NDepend project output directory. The preferred option to provide a previous analysis result to compare with during an analysis is to use: NDepend > Project Properties > Analysis > Baseline for Comparison You can use the option /AnalysisResultToCompareWith in special scenarios where using Project Properties doesn't work.

  • /QualityGateCheck [/OutJson file|-] [/OutSarif file]: to run the analysis, the rules and the quality gates without building a report, and get the result in JSON and/or SARIF. See the section below.
  • /IssueCheck ["rule or query"] [/OutJson file|-] [/OutSarif file]: to run the analysis and the rules without building a report, and get only the issues in JSON and/or SARIF: all issues, or the issues of a rule or of a query. See the section below.
  • /Help: to display the current help on console
  • Adjusting the code queries execution time-out

  • If you need to adjust the code queries execution time-out used during analysis through NDepend.Console.exe just run VisualNDepend.exe once on the machine running NDepend.Console.exe and choose a time-out value in VisualNDepend > Tools > Options > Code Query > Query Execution Time-Out.

    This parameter is persisted in the file VisualNDependOptions.xml that can be found in the directory VisualNDepend > Tools > Options > Export / Import / Reset Options > Open the folder containing the Options File

Check Quality Gates and Issues without a Report, for AI Coding Agents and Scripts

Two switches let NDepend.Console.exe analyze the code, run the rules, and write the result in JSON and/or SARIF. No HTML report is built:

  • /QualityGateCheck: runs the rules and the quality gates, and outputs the quality gates status, the rules violated and all the issues. The exit code tells whether a quality gate fails.
  • /IssueCheck ["rule or query"]: runs the rules and outputs only the issues: all the issues, or the issues of one rule or of one query. The quality gates are not evaluated. The exit code tells whether there are issues.

These modes are typically run by an AI coding agent (Claude Code, Codex, GitHub Copilot...) to verify the structure of the code it produces after each change: new issues since the baseline, rules violated, quality gates that fail, with the source file and line of each issue and how to fix it.

/QualityGateCheck and /IssueCheck run with a Developer license or a Build Machine license. Building the HTML report with NDepend.Console.exe still requires a Build Machine license.

Arguments

  • /QualityGateCheck: to run the analysis, the rules and the quality gates without building a report. When neither /OutJson nor /OutSarif is specified, the JSON file QualityGateCheck.json is written in the project output directory.
  • /IssueCheck ["rule or query"]: to run the analysis and the rules without building a report, and output only the issues.
    Without a value all the issues are output. Else the value, surrounded with double quotes when it contains spaces, designates:
    • a rule id like ND1000, or like CA1822 for an imported Roslyn rule,
    • or a rule name like "Avoid types too big",
    • or the name of a query that matches issues, like "New issues since baseline".
    The comparison ignores case. An unknown name, a rule not active, a query that doesn't match issues or several rules or queries with the same name is an error. When neither /OutJson nor /OutSarif is specified, the JSON file IssueCheck.json is written in the project output directory.
  • /OutJson file: to write the result in a JSON file: the quality gates status (/QualityGateCheck only), the rules violated and the issues, see the JSON output reference.
    With /OutJson - the JSON is written on the standard output and all logs are written on the standard error. This way the JSON can be piped to another process.
  • /OutSarif file: to write the issues in a SARIF 2.1.0 file, see the SARIF output reference.

Like other paths, /OutJson and /OutSarif paths must be absolute, relative to the project file location starting with .\ or ..\ (like .\out\qg.json), or prefixed with an environment variable or a path variable. A file name alone like qg.json is refused.

/QualityGateCheck and /IssueCheck cannot be used together. The other analysis arguments can be used with them like /InDirs, /CoverageFiles, /RuleFiles, /OutDir, /AnalysisResultToCompareWith, /Concurrent, /Silent or /ForceReturnZeroExitCode. The arguments related to the report or to the trend are refused: /ViewReport, /XslForReport, /KeepXmlFilesUsedToBuildReport, /LogTrendMetrics, /PersistHistoricAnalysisResult and /EmitVisualNDependBinXml.

The analysis result is persisted in the project output directory as usual. This way it can be used as the baseline of the next analysis, and it can be loaded by the NDepend Visual Studio extension, VisualNDepend.exe or the NDepend MCP server.

Exit code

  • 0: with /QualityGateCheck all quality gates pass or warn, with /IssueCheck there is no issue.
  • 2: with /QualityGateCheck at least one quality gate fails, with /IssueCheck there is at least one issue (0 with /ForceReturnZeroExitCode).
  • 1: error, like a wrong argument, a license issue, no assembly to analyze, or an /IssueCheck value that doesn't designate a rule or a query that matches issues.

Distinct exit codes let an agent or a script tell apart "the code must be fixed" from "NDepend could not run".

Examples

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /QualityGateCheck

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /QualityGateCheck /OutJson .\out\qg.json /OutSarif .\out\qg.sarif

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /QualityGateCheck /OutJson - > qg.json 2> ndepend.log

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /IssueCheck /OutSarif .\out\issues.sarif

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /IssueCheck ND1000 /OutSarif .\out\ND1000.sarif

>NDepend.Console.exe C:\Dev\MyApp\MyApp.ndproj /IssueCheck "New issues since baseline" /OutJson -

>dotnet $NDependInstallDir$\net10.0\NDepend.Console.MultiOS.dll /mnt/c/Dev/MyApp/MyApp.ndproj /QualityGateCheck /OutJson -

Here is an instruction that can be added to an agent instruction file like AGENTS.md or CLAUDE.md:

After each change, build the solution and run:
  NDepend.Console.exe MyApp.ndproj /QualityGateCheck /OutJson -
Read the JSON written on the standard output.
Fix every issue where "isNew" is true, starting with the highest severity,
using "explanation" and the rule "howToFix". Repeat until "status" is not "Fail"
and "summary.newIssuesCount" is 0.

Same export from NDepend.API

/QualityGateCheck and /IssueCheck rely on these NDepend.API methods of NDepend.Analysis.ExtensionMethodsProjectAnalysis. The export methods return the JSON or SARIF content as a string:

  • TryExportQualityGatesAndIssues(): the quality gates and all the issues, like /QualityGateCheck.
  • TryGetIssues(): the issues of a rule or of a query from its rule id, rule name or query name like /IssueCheck "rule or query", or the issues matched by a code query compiled.
  • TryExportIssues(): extends IEnumerable<IIssue> to export some issues without quality gates, like /IssueCheck.
var analysisResult = analysisResultRef.Load();
// IssueReferenceRecord.Yes: the issue explanations are exported in the messages
var issuesSet = analysisResult.ComputeIssues(TimeSpan.FromMinutes(5), IssueReferenceRecord.Yes, out var justMyCode, out _);
if (analysisResult.TryGetIssues(issuesSet, null, "ND1000", out var issues, out string issuesQueryName,
                                out string failureReason, justMyCode) &&
    issues.TryExportIssues(analysisResult, issuesSet, null, IssuesExportFormat.Sarif,
                           out string sarif, out failureReason, issuesQueryName)) {
   File.WriteAllText(@"C:\Dev\MyApp\out\ND1000.sarif", sarif);
}

Create a Project File with NDepend.Console

NDepend.Console.exe can be used to create an NDepend project file. This is useful to create NDepend project(s) on-the-fly from a script.

Other ways to create an NDepend project is either by using VisualNDepend.exe or by creating a .NET program that rely on NDepend.API as explained here

Here are arguments required to created a project with NDepend.Console.exe:

  • To do so the first argument must be /CreateProject or /cp (case-insensitive).
  • The second argument must be the project file path to create. The file name must have the extension .ndproj. If you need to specify a path that contains a space character use double quotes "...". The specified path can be either an absolute path (with drive letter C:\ or UNC \\Server\Share format), a path relative to the current directory (obtained with System.Environment.CurrentDirectory), or a file name in the current directory.
  • Then at least one or several sources of code to analyze must be precised. A source of code to analyze can be:

    • A path to a Visual Studio solution file.

      The solution file extension must be .sln.
      The vertical line character '|' can follow the path to declare a filter on project names (as explained in this section). If no filter is precised the default filter -test is defined. If you need to specify a path or a filter that contains a space character use double quotes "...".
      Example: "..\My File\MySolution.sln|filterIn -filterOut".

    • A path to a Visual Studio project file. The project file extension must be within: .csproj .vbproj .proj

    • A path to a compiled assembly file. The compiled assembly file extension must be within: .dll .exe .winmd

    Notice that source of code paths can be absolute or relative to the project file location.
    If you need to specify a path or a filter that contains a space character use double quotes "...".

  • Here is a short example that illustrates arguments to create a project:

    >NDepend.Console.exe /cp C:\temp\MyProj.ndproj "..\src\MySolution.sln|-filter"
    "E:\My Dir\MyAssembly1.dll" E:\MyDir\MyAssembly2.dll
    

    Windows absolute paths are formatted like "C:\Dir" and "\\Server\Share" while Linux or macOS absolute paths are formatted like "/mnt/c/dir/". Thus absolute paths are compatible between Linux and macOS, but incompatible with Windows (and vice-versa). As a consequence if an NDepend project or analysis result is aimed to be used on various OS there are a few caveats:

    • If an NDepend project is used on various OS kinds, it must reference only relative paths. These referenced relative paths are relative to the NDepend project file location.
    • When using $NDependInstallDir$\NDepend.Console.exe or $NDependInstallDir$\net10.0\NDepend.Console.MultiOS.dll to create a project, absolute paths provided are transformed to relative paths when possible.
    • As explained in the documentation Understanding NDepend Analysis Inputs the primary sources of code analyzed are .NET assemblies, their PDB files and the source files referenced by the PDB files.

      When compiling an assembly, the PDB files are referencing absolute source files paths with the format of the underlying OS. NDepend extracts and stores these absolute paths in the analysis results it produces.

      As a consequence if an NDepend analysis result is consumed on a different OS, (for example an analysis result produced on Linux is opened with VisualNDepend.exe on Windows) the absolute source file paths that it contain are incompatible and cannot be used to locate or open the source file path.

      However an NDepend analysis result stores all source files analyzed zipped. Even when the absolute paths are OS incompatible, the source files can still be unzipped and even compared between two analysis results.

Register a License or Start Evaluation with NDepend.Console

NDepend.Console.exe can be used to register a license on a machine, or to start evaluation. Here are console arguments to use (case insensitive):

  • /RegEval : Start the NDepend 14 days evaluation on the current machine.
  • /RegLic XYZ : Register a seat of the license key XYZ on the current machine. Notice that the license XYZ must be a Build Machine license to run NDepend.Console.exe, except with the switches /QualityGateCheck and /IssueCheck that also run with a Developer license.
  • /UnregLic : Unregister a seat of the license key already registered on the current machine.
  • /RefreshLic : Refresh the license data already registered on the current machine. This is useful when the license changes upon renewal.

Each of these operation requires internet access to do a roundtrip with the NDepend server. If the current machine doesn't have internet access, a procedure is proposed to complete the operation by accessing manually the NDepend server from a connected machine.

Start NDepend Evaluation on a machine not connected to internet

Register a GitHub PAT with NDepend.Console

A GitHub PAT (Personal Access Token) can be registered on a machine. This way when NDepend needs to access GitHub, it can use such PAT. Here are console arguments to use (case insensitive):

  • /RegGitHubPAT XYZ : Register the GitHub PAT XYZ on the current machine.
  • /UnregGitHubPAT : Unregister the GitHub PAT actually registered on the current machine.

As explained above, when using NDepend.Console.exe to run an analysis, a PAT can be provided with the switch GitHubPAT. In such case, during analysis the PAT provided overrides the PAT registered on the machine (if any).

/QualityGateCheck and /IssueCheck JSON Output Reference

The JSON written by /QualityGateCheck /OutJson and by /IssueCheck /OutJson is described by this JSON schema: https://www.ndepend.com/schemas/issues-export/1.0.json. The property $schema of the JSON references it, so editors and tools can validate the JSON and provide completion.

Versioning: the property schemaVersion is "1.0". Future 1.x versions only add properties. A breaking change (a property renamed, removed or with a different meaning) bumps the major version and the schema URL. Hence a JSON consumer should ignore unknown properties.

Here is a /QualityGateCheck sample, with only one quality gate, one rule and one issue shown:

{
  "$schema": "https://www.ndepend.com/schemas/issues-export/1.0.json",
  "schemaVersion": "1.0",
  "tool": { "name": "NDepend", "version": "2027.1.0.9818" },
  "project": { "name": "MyApp", "filePath": "C:\\Dev\\MyApp\\MyApp.ndproj" },
  "analysisDate": "2026-09-24T13:08:14.1234567+02:00",
  "baseline": {
    "description": "Compare with the analysis result obtained on 2026 September 20 Sunday 08:00",
    "date": "2026-09-20T08:00:00.0000000+02:00"
  },
  "issuesQuery": null,
  "status": "Fail",
  "summary": {
    "qualityGatesCount": 12,
    "qualityGatesFailCount": 1,
    "qualityGatesWarnCount": 1,
    "rulesViolatedCount": 26,
    "issuesCount": 342,
    "newIssuesCount": 3,
    "fixedIssuesCount": 1
  },
  "qualityGates": [
    {
      "name": "Critical Rules Violated",
      "status": "Fail",
      "value": 1.0,
      "valueString": "1 rules",
      "unit": "rules",
      "failThreshold": 0.0,
      "warnThreshold": null,
      "moreIsBad": true
    }
  ],
  "rules": [
    {
      "id": "ND1000",
      "name": "Avoid types too big",
      "category": "Code Smells",
      "provider": "CodeQueryRule",
      "isCritical": false,
      "issuesCount": 4,
      "description": "This rule matches types with more than 200 lines of code...",
      "howToFix": "Types where NbLinesOfCode > 200 are extremely complex...",
      "helpUri": "https://www.ndepend.com/default-rules/NDepend-Rules-Explorer.html?ruleid=ND1000#!"
    }
  ],
  "issues": [
    {
      "ruleId": "ND1000",
      "severity": "High",
      "isNew": true,
      "codeElement": "MyApp.Services.OrderService",
      "isTestCode": false,
      "sourceFile": "C:\\Dev\\MyApp\\Services\\OrderService.cs",
      "line": 12,
      "column": 4,
      "explanation": "MyApp.Services.OrderService has 412 lines of code",
      "debt": "1h 32min",
      "debtMinutes": 92.0,
      "annualInterest": "20min"
    }
  ]
}

Properties

  • issuesQuery: with /IssueCheck "rule or query" the name of the rule or of the query whose issues are output, else null.
  • status: Pass, Warn or Fail, the worst status among all quality gates. With /QualityGateCheck the exit code is 2 when Fail.
    /IssueCheck doesn't evaluate the quality gates: status, qualityGates, summary.qualityGatesCount, summary.qualityGatesFailCount, summary.qualityGatesWarnCount and summary.fixedIssuesCount are then null.
  • baseline: the analysis result compared with, or null when there is no baseline. When there is no baseline summary.newIssuesCount, summary.fixedIssuesCount and each issues[].isNew are null. On the first analysis of a project the baseline is the analysis itself, hence no issue is new. The baseline is defined in Project Properties > Analysis > Baseline for Comparison, or with the argument /AnalysisResultToCompareWith.
  • summary: counts of quality gates, rules violated, issues, new issues and fixed issues. Fixed issues are counted but not listed.
  • qualityGates[]: name, status, value (null when it cannot be computed, then the quality gate passes), valueString formatted with the unit, failThreshold, warnThreshold (null when not defined) and moreIsBad.
  • rules[]: the rules that have at least one issue: id (like ND1000, or the rule name for a rule without id), name, category, provider (CodeQueryRule for an NDepend rule, Roslyn or Resharper for imported issues), isCritical, issuesCount, description and howToFix in Markdown (with code samples for many rules), and helpUri the online documentation of NDepend default rules.
  • issues[]: all the issues, or with /IssueCheck "rule or query" the issues of the rule or of the query, suppressed issues excluded, sorted by severity (highest first), then new issues first: ruleId, severity (Blocker, Critical, High, Medium or Low), isNew, codeElement the full name of the code element concerned, isTestCode, sourceFile, line and column (null when the source file is unknown), explanation, debt the estimated cost to fix the issue (also in debtMinutes) and annualInterest the estimated yearly cost of leaving it unfixed. See Technical Debt for these notions.

/QualityGateCheck and /IssueCheck SARIF Output Reference

The file written by /QualityGateCheck /OutSarif and by /IssueCheck /OutSarif conforms to the standard SARIF 2.1.0 format and references its schema https://json.schemastore.org/sarif-2.1.0.json. It can be consumed by GitHub code scanning, Azure DevOps, IDE SARIF viewers and AI coding agents. Here is how NDepend fills it:

  • runs[0].tool.driver.rules[]: the rules that have at least one issue, with id, name, shortDescription, fullDescription (the rule description), help.markdown (how to fix) and helpUri for NDepend default rules. properties holds category, provider and isCritical.
  • runs[0].results[]: one result per issue, with ruleId, ruleIndex and message.text (the rule name followed by the issue explanation, or else by the code element and the values of the rule columns).
  • level: severity Blocker and Critical map to error, High and Medium map to warning, Low maps to note.
  • locations: physicalLocation with the source file URI, startLine and startColumn when known, and a logicalLocation with the full name of the code element.
  • baselineState: new or unchanged when a baseline is available. Fixed issues are not listed.
  • partialFingerprints: ndependIssue/v1 is a key stable from one analysis to the next, used by SARIF consumers to track an issue over time.
  • result properties: severity, debt, debtMinutes, annualInterest and isTestCode.
  • runs[0].properties: SARIF has no notion of quality gate, hence with /QualityGateCheck qualityGateStatus and qualityGates[] (name, status, value, valueString, failThreshold, warnThreshold) are in the run property bag. With /IssueCheck "rule or query" the property bag holds issuesQuery, the name of the rule or of the query.