SlimDep for Visual Studio CodeDetect and remove unused NuGet package references directly inside VS Code — with a tree view panel and inline CodeLens on every RequirementThe SlimDep CLI must be installed as a .NET global tool:
FeaturesUnused Packages Tree ViewA dedicated "Unused NuGet Packages" panel appears in the Explorer sidebar whenever a Inline CodeLens on
|
| Command | Description |
|---|---|
SlimDep: Scan for Unused Packages |
Scan all .csproj files in the workspace |
SlimDep: Remove All Unused Packages |
Auto-remove all unused packages from all projects |
SlimDep: Refresh |
Re-run the scan and refresh the tree view |
Run any command via the Command Palette (Ctrl+Shift+P / Cmd+Shift+P).
Usage
- Open a .NET workspace that contains
.csprojfiles - Run
dotnet restorein the terminal (required before scanning) - Open the Command Palette → SlimDep: Scan for Unused Packages
- Review unused packages in the "Unused NuGet Packages" panel in the Explorer
- Click SlimDep: Remove All Unused Packages to auto-remove them
- Run
dotnet restoreagain after removal
Commands In Detail
SlimDep: Scan for Unused Packages
Command ID: slimdep.scan
Scans all .csproj files found in the current workspace for unused NuGet package references.
How to run:
- Command Palette (
Ctrl+Shift+P) → typeSlimDep: Scan - Click the Refresh button (↻) in the Unused NuGet Packages panel title bar
What happens:
- A progress indicator appears in the status bar while scanning
- Each
.csprojis scanned individually via theslimdepCLI - Results populate the Unused NuGet Packages tree view in the Explorer
- Unused packages are also annotated inline with
⚠ UnusedCodeLens above their<PackageReference>line in the.csprojeditor
Example — tree view result after scan:
UNUSED NUGET PACKAGES
└── MyApp.Api.csproj (2 unused)
├── Newtonsoft.Json 13.0.3
└── Serilog.Sinks.File 5.0.0
└── MyApp.Core.csproj (1 unused)
└── CsvHelper 30.0.1
Example — CodeLens in .csproj editor:
⚠ Unused — run slimdep fix to remove
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
SlimDep: Remove All Unused Packages
Command ID: slimdep.fix
Removes all unused packages found in the last scan from their respective .csproj files.
How to run:
- Command Palette (
Ctrl+Shift+P) → typeSlimDep: Remove - Click the trash icon (🗑) in the Unused NuGet Packages panel title bar
- Click the
⚠ Unused — run slimdep fix to removeCodeLens annotation in the.csprojeditor
What happens:
- A confirmation dialog appears showing how many packages will be removed and from how many projects
- After confirming, the
slimdep fixCLI command runs for each affected project - The tree view and CodeLens annotations are cleared
- A notification reminds you to run
dotnet restore
Example confirmation dialog:
SlimDep: Remove 3 unused package(s) from 2 project(s)?
[Remove] [Cancel]
⚠ This writes changes to your
.csprojfiles. Always review the scan results before confirming.
SlimDep: Refresh
Command ID: slimdep.refresh
Re-runs the scan and refreshes the tree view with the latest results. Identical to Scan but accessible directly from the panel title bar.
How to run:
- Click the ↻ icon in the Unused NuGet Packages panel title bar
- Command Palette (
Ctrl+Shift+P) → typeSlimDep: Refresh
Typical Workflow
1. dotnet restore ← must run before scanning
2. Scan (Ctrl+Shift+P) ← finds unused packages
3. Review tree view ← check what would be removed
4. Remove (confirm dialog) ← writes changes to .csproj files
5. dotnet restore ← update the lockfile after removal
Settings
| Setting | Default | Description |
|---|---|---|
slimdep.toolPath |
slimdep |
Path to the slimdep executable. Override if you installed the tool to a custom location. |
slimdep.autoScanOnOpen |
false |
Automatically scan when a .csproj file is opened in the editor. |
Configure in File → Preferences → Settings → search for SlimDep.
How It Works
The extension delegates all analysis to the slimdep CLI tool, which:
- Reads
obj/project.assets.jsonto discover package DLLs - Uses Roslyn to parse
.csfiles and extractusingdirectives - Uses .NET reflection metadata to extract namespaces exported by each package
- Flags any package whose namespaces never appear in a
usingdirective
No build is required — only dotnet restore.
Known Limitations
- Packages used via fully-qualified names (no
usingdirective) will be reported as unused - Does not analyse XAML, Razor, or other non-C# source files
- Requires
obj/project.assets.json— rundotnet restorebefore scanning
CLI Tool
SlimDep is also available as a standalone CLI tool for terminal and CI pipeline use:
slimdep scan C:\Dev\MySolution
slimdep fix C:\Dev\MySolution --dry-run
Install: dotnet tool install --global SlimDep --prerelease
License
MIT © 2026 Vinay Diddi