NetSnap is a CLI tool designed for creating detailed snapshots of the structure and content of .NET projects. It simplifies project analysis and documentation by capturing all relevant files and their contents, while ignoring unnecessary files and directories.
- Scans a .NET project directory for files and captures their content.
- Automatically ignores common build artifacts (
bin,obj) and irrelevant files (.gitignore, images, etc.). - Supports customizable output file paths.
- Provides clear, human-readable snapshots for easy sharing or documentation.
- Optional output splitting (
--split) to avoid huge snapshot files. - Optional per-
csprojsnapshots (--by-csproj) to generate one file per project.
Install the NetSnap tool globally using the .NET CLI:
dotnet tool install --global NetSnapUpdate to the latest version:
dotnet tool update --global NetSnapAfter installation, the command will be available as:
netsnapnetsnap [sourcePath] [outputPathOrDir] [--split <size>] [--by-csproj]-
sourcePath(optional)Directory to scan. If omitted, uses the current directory (Release) or the project directory (Debug).
-
outputPathOrDir(optional)Where to write the snapshot(s).
- If it looks like a file path (has an extension), NetSnap writes to that file (default:
snapshot.txtinsidesourcePath). - If it looks like a directory (exists as a directory, or has no extension), NetSnap writes results into that directory.
- If it looks like a file path (has an extension), NetSnap writes to that file (default:
-
--split <size>Split output into multiple files with a maximum size.
Supported formats:
- Raw bytes:
500000 - With suffix:
500KB,5MB,1GB(case-insensitive)
Notes:
- When splitting a single output file, NetSnap writes:
snapshot.txt,snapshot_2.txt,snapshot_3.txt, ... - Splitting is based on UTF-8 byte size.
- Raw bytes:
-
--by-csprojGenerate separate output per
*.csproj.- Output file names are derived from the
.csprojfile name. - Example:
MyProject.csproj→MyProject.txt - If used together with
--split, large projects produce:MyProject.txt,MyProject_2.txt,MyProject_3.txt, ...
- Output file names are derived from the
-
--help,-h,/?Show help.
Create a single snapshot file (default output is snapshot.txt in the source folder):
netsnap .Create a single snapshot file at a custom path:
netsnap . .\snapshot.txtSplit a single snapshot into chunks of up to 5MB:
netsnap . .\snapshot.txt --split 5MBCreate one snapshot per .csproj in an output folder:
netsnap . .\out --by-csprojCreate one snapshot per .csproj and split each project snapshot into 2MB chunks:
netsnap . .\out --by-csproj --split 2MBThe output is a human-readable text file with:
- project headers per
.csproj - file paths (relative to
sourcePath) - file contents
Example (simplified):
Project Snapshot:
### Project: MyProject.csproj ###
File: src/Program.cs
-------- File Content --------
...
------------------------------
### End of Project: MyProject.csproj ###
NetSnap intentionally skips:
- directories:
bin,obj, and hidden folders (starting with.) - files:
.gitattributes,.gitignore, and the default output file namesnapshot.txt - extensions:
.img,.jpeg,.webp
To avoid recursively capturing generated snapshots, NetSnap also ignores the output file itself and split parts:
snapshot.txtsnapshot_2.txt,snapshot_3.txt, ...<Project>.txt,<Project>_2.txt, ... (when--by-csprojis used)
dotnet build -c Releasedotnet run --project .\NetSnap\NetSnap.csproj -- . .\snapshot.txtdotnet test- Snapshots are written using UTF-8 (without BOM).
- Large file contents are streamed line-by-line to reduce memory pressure.
- If you commit generated snapshot files into the repository, consider adding them to
.gitignore.
MIT.