loc - Lines of Code
The loc command counts lines of code in your .NET projects and solutions. It produces a breakdown of total lines, logical lines of code, blank lines, comment lines, and brace-only lines, followed by a list of the top 10 largest files by logical LOC.
When a directory is provided and it contains exactly one .slnx solution file, all projects in that solution are analyzed. Otherwise the path is treated as a .csproj file or a plain directory.
nmbl loc <ProjectOrSolutionPath> [--exclude-generated]
ProjectOrSolutionPath- Path to a.csprojfile, a.slnxsolution file, a project directory, or.for the current directory.--exclude-generated(optional) - Exclude common auto-generated files such as*.Designer.cs,*.g.cs, and*.AssemblyInfo.cs.
Prints a summary box followed by a top-10 files table.
Analyzing 42 C# file(s)...
╔══════════════════════════════════════════════════════════════╗
║ LINES OF CODE SUMMARY ║
╠══════════════════════════════════════════════════════════════╣
║ Files Analyzed: 42 ║
║ Total Lines: 4,821 ║
║ Logical Lines (LOC): 3,104 ║
║ Blank Lines: 612 ║
║ Comment Lines: 389 ║
║ Brace-Only Lines: 716 ║
╚══════════════════════════════════════════════════════════════╝
Top 10 files by logical lines of code:
File LOC Total
------------------------------------------------------------------------------
src/Services/OrderService.cs 312 418
src/Controllers/OrdersController.cs 187 241
- Total Lines — every line in the file, including blank lines and comments.
- Logical Lines (LOC) — lines that contain executable code, excluding blanks, comments, and brace-only lines. This is the primary size metric.
- Blank Lines — empty or whitespace-only lines.
- Comment Lines — lines consisting entirely of a comment.
- Brace-Only Lines — lines containing only
{or}.
0- Success, including when no C# files are found.1- The required path argument is missing or an unexpected error occurs.
nmbl loc src/MyProject/MyProject.csproj
nmbl loc MySolution.slnx
Counts lines across all projects in the solution.
nmbl loc .
If the current directory contains exactly one .slnx file, the solution is analyzed. Otherwise all C# files in the directory tree are analyzed.
nmbl loc . --exclude-generated
Use this option to skip common generated files (for example, Foo.Designer.cs) so the metrics focus on hand-written code.
# Capture a baseline
nmbl loc MySolution.slnx > metrics/loc-baseline.txt
# After development, capture again
nmbl loc MySolution.slnx > metrics/loc-current.txt
nmbl loc src/Core/Core.csproj
nmbl loc src/Infrastructure/Infrastructure.csproj
nmbl loc src/Web/Web.csproj
Compare the relative sizes of different architectural layers.
nmbl loc MySolution.slnx
nmbl cc MySolution.slnx
nmbl cogc MySolution.slnx
nmbl regions MySolution.slnx
nmbl todos MySolution.slnx
nmbl loc MySolution.slnx | tee build-artifacts/loc-report.txt