Spargine Dev Tool: For Microsoft .NET Developers

In 2016, I launched my first free application for Microsoft .NET developers, designed to tackle common challenges developers frequently encounter. Since its initial release, I have continuously expanded its features and functionality to provide even greater value.

One of the app’s core features from the start was the ability to clean up temporary and cached files that Visual Studio, SQL Server, and other applications leave behind. These residual files can lead to issues like failed builds, debugging errors, and unnecessary clutter. By automating this cleanup process, the tool helps developers maintain a smoother workflow.

Another essential feature I introduced allows users to quickly scan their computers for source code and create backups. This functionality was born out of my own frustrations with source control systems occasionally losing code. By providing an additional layer of security, this feature has proven invaluable to many developers.

Now, with the release of the third major version, I have transformed the application into a Microsoft .NET global tool. This significant upgrade enhances performance and makes it seamlessly accessible from the command line. Developers can now easily integrate it into build scripts or use it in pre/post-build events within Visual Studio, streamlining their development process.

I remain committed to improving and evolving this tool to better serve the developer community. If you have suggestions or feedback on how to make it even more useful, I would love to hear from you!

Demo: See the Spargine Dev Tool in Action!

Watch how the Spargine Dev Tool effortlessly cleans up development clutter, backs up your source code, and resolves pesky build issues in just seconds!


Spargine Dev Tool — Overview

What Is It?

Spargine Dev Tool is a Windows .NET 10 command-line utility designed to help developers keep their machines clean and their source code backed up. It provides two primary operations:

Command Purpose
backup Backs up Visual Studio solution folders to a configurable destination (OneDrive or local).
clean Deletes temporary and cached files generated by Visual Studio, .NET SDK, SQL Server, NuGet, Azure tooling, JetBrains tools, and Windows.

Commands

backup — Back Up Source Code

Scans fixed drives for Visual Studio solution roots and copies them to a backup destination. The backup destination is resolved automatically in the following priority order:

  1. OneDrive for Business folder (if present) → <OneDrive>\Backup
  2. Personal OneDrive folder (if present) → <OneDrive>\Backup
  3. Local fallback%USERPROFILE%\AppData\Local\Spargine\Backup

Backup folders are organized as:

<BackupRoot>\<MACHINENAME>\<USERNAME>\<MODE>\<TIMESTAMP>\

Options

Option Alias Description
--turbo Turbo mode: only backs up files with the Archive attribute set (i.e. changed since last backup). Clears the Archive attribute after copying.
--rescan Forces a re-scan of all fixed drives for new solution roots, regardless of when the last scan ran (normally re-scans every 7 days).
--af <PATH> --addfolder Adds a folder path to the backup configuration.
--rf <PATH> --removefolder Removes a folder path from the backup configuration.
--cleanprojects After backing up, deletes obj, bin, and appbin subdirectories from detected solution roots.
--ecp --enablecleanprojects Marks newly added or re-enabled folders as project roots so --cleanprojects applies to them.
--verbosity <LEVEL> Controls console output: quiet, minimal, normal, detailed, diagnostic.

Examples

# Standard full backup
spargine backup

# Turbo backup — changed files only
spargine backup --turbo

# Add a new folder to the backup list
spargine backup --addfolder "D:\MyProject"

# Remove a folder from the backup list
spargine backup --removefolder "D:\OldProject"

# Back up and clean build artifact directories
spargine backup --cleanprojects

# Force a drive re-scan for new solution roots
spargine backup --rescan

Drive Scan Behaviour

On the first run (and every 7 days thereafter, or whenever --rescan is passed), the tool:

  1. Enumerates all fixed drives.
  2. Skips well-known system paths (Windows, Program Files, Users, $Recycle.Bin, OneDrive sync roots, etc.).
  3. Searches each top-level directory for files matching known project/solution extensions (.sln, .csproj, .vbproj, .fsproj, and many others).
  4. Prompts interactively — one-by-one for fewer than 5 new folders, or via a multi-select list for 5 or more — to include or exclude each discovered root.

Declined folders are saved as disabled entries so they are not re-prompted on the next scan.

Backup Retention

Old backup folders are automatically deleted based on DaysToKeepBackedUpFolders (default: 7 days). Read-only attributes are stripped before deletion to avoid access-denied errors.


clean — Clean Temp and Cache Files

Deletes temporary and cached files from a configurable list of folders.

Options

Option Alias Description
--nuget Also clears the local NuGet global package cache (dotnet nuget locals all -c).
--turbobackup Runs a turbo backup after cleaning.
--af <PATH> --addfolder Adds a folder to the clean list. --af and --rf are mutually exclusive.
--rf <PATH> --removefolder Removes a folder from the clean list. --af and --rf are mutually exclusive.
--verbosity <LEVEL> Controls console output level.

Examples

# Standard clean
spargine clean

# Clean and also clear the NuGet cache
spargine clean --nuget

# Add a folder to the clean list
spargine clean --addfolder "C:\Temp\MyCache"

# Remove a folder from the clean list
spargine clean --removefolder "C:\Temp\OldCache"

# Back up changed files then clean
spargine clean --turbobackup

What Gets Cleaned

The cleaner targets the following categories of folders automatically on Windows:

Category Examples
Windows OS INetCache, WebCache, WER (error reports), Explorer thumbnail cache, %windir%\Temp
Visual Studio ComponentModelCache, Designer\ShadowCache, DiagnosticsHub, VSApplicationInsights, VisualStudio Services, GitHubVisualStudio caches, VS backup files, VSFeedbackIntelliCodeLogs
IsolatedStorage %LOCALAPPDATA%\IsolatedStorage
.NET SDK / MSBuild / NuGet toolResolverCache, NuGetScratch, NuGetTemp, MSBuildTemp, NuGet\v3-cache
IIS Express TraceLogFiles, Logs
SQL Server SSMS backup files, RSTempFiles
ASP.NET Temporary ASP.NET Files (all versions)
Azure tooling Azure CLI logs, Azure Data Studio logs and cache, Azure Storage Emulator logs
JetBrains ReSharper / Rider SolutionCaches and log folders (local and roaming)
Test / Coverage Microsoft\CodeCoverage, *.coverage temp files
Crash dumps %LOCALAPPDATA%\CrashDumps
Other CryptnetUrlCache, Zscaler logs, CodeRush logs, SubMain cache

Process-Guarded Folders

Some folders are unsafe to delete while a related application is running. The cleaner checks for active processes before each run and automatically skips the following folders if their associated process is detected:

Process guard Folders skipped
devenv (Visual Studio) ComponentModelCache, Designer\ShadowCache, DiagnosticsHub, VSApplicationInsights, VisualStudio Services, GitHubVisualStudio\BlobCache, GitHubVisualStudio\GraphQLCache, IsolatedStorage, VSFeedbackIntelliCodeLogs
azuredatastudio AzureDataStudio\logs, AzureDataStudio\CachedData

Process detection uses Spargine’s ServiceHelper.IsProcessRunning() and runs once per clean operation. Only the unique process names referenced by configured folders are checked, keeping startup overhead minimal.

Folder Configuration Persistence

  • The clean folder list is persisted to a configuration file.
  • Folders added via --addfolder are saved and cleaned on every subsequent run until removed.
  • If a configured folder no longer exists on disk it is skipped, not removed from the list, so it will be cleaned again if the path reappears.
  • SkipIfProcessRunning metadata is always kept in sync with the built-in defaults, so upgrading the tool will apply new process guards even to folders already in your config file.

Installation Guide

Installing the dotNetTips.Spargine.Dev.Tool is quick and easy. Follow the steps below to install, update, or remove the tool using the .NET CLI.

Install the Tool

To install or update the tool globally on your system, open a command window and run:

dotnet tool update --global dotNetTips.Spargine.Dev.Tool

Uninstall the Tool

If you need to remove the tool from your system, use the following command:

dotnet tool uninstall --global dotNetTips.Spargine.Dev.Tool

More Information

For the latest updates, release notes, and detailed package information, visit:
NuGet Package: dotNetTips.Spargine.Dev.Tool

Future Work: Upcoming Features

I am actively working on expanding and improving dotNetTips.Spargine.Dev.Tool to make it even more powerful and efficient. Below are some of the key features that will be added soon.

Code Backup Enhancements

  1. Customizable File Type Exclusions – Add support for excluding specific file types from backups. Currently, the default exclusions include: aps, bak, cache, cachefile, csdef, dbmdl, dll, docstates, dotCover, gpState, JustCode, ncb, nupkg, opendb, opensdf, optpfx, plg, props, psess, publishproj, publishsettings, pubxml, sap, schemaview, sdf, snk, suo, targets, temp, tmp, user, userosscache, userprefs, vsp, vssscc, vspscc, vspx, zip, pdb, compiled, rsp
  2. .gitignore Integration – Automatically exclude file types listed in the project’s .gitignore file.

I am always open to feedback and suggestions! If you have ideas for additional features or improvements, feel free to reach out.

Request Additional Cleanup Folders

If you have a folder you think should be permanently added to this list, feel free to email me, and I will consider adding it in the next version!

Summary

I hope the Spargine Dev Tool proves as valuable to you and your team as it has been for me in my daily workflow!

Whether you are backing up source code, cleaning development folders, or resolving build issues, this tool is designed to enhance productivity and streamline your development process.

Got feature ideas?
Encountered any issues?

Feel free to reach out—I would love to hear your feedback! dotNetDave@live.com

Thank you for your support, and happy coding!

Pick up any books by David McCarter by going to Amazon.com: http://bit.ly/RockYourCodeBooks

One-Time
Monthly
Yearly

Make a one-time donation

Make a monthly donation

Make a yearly donation

Choose an amount

$5.00
$15.00
$100.00
$5.00
$15.00
$100.00
$5.00
$15.00
$100.00

Or enter a custom amount

$

Your contribution is appreciated.

Your contribution is appreciated.

Your contribution is appreciated.

DonateDonate monthlyDonate yearly

If you liked this article, please buy David a cup of Coffee by going here: https://www.buymeacoffee.com/dotnetdave

© The information in this article is copywritten and cannot be reproduced in any way without express permission from David McCarter.


Discover more from dotNetTips.com

Subscribe to get the latest posts sent to your email.

Leave a Reply