| name | dotnet-dependency |
| description | This skill should be used when investigating .NET project dependencies, understanding why packages are included, listing references, or auditing for outdated/vulnerable packages. |
.NET Dependencies
Investigate and manage .NET project dependencies using built-in dotnet CLI commands.
When to Use This Skill
Invoke when the user needs to:
- Search for NuGet packages or find latest versions
- Add, update, or remove package references
- Understand why a specific NuGet package is included
- List all project dependencies (NuGet packages or project references)
- Find outdated or vulnerable packages
- Trace transitive dependencies
- Manage dotnet tools (search, install, update)
Quick Reference
| Command | Purpose |
|---|
dotnet package search <term> | Search NuGet for packages |
dotnet package search <name> --exact-match | List all versions of a package |
dotnet add package <id> | Add/update package to latest version |
dotnet add package <id> -v <ver> | Add/update package to specific version |
dotnet remove package <id> | Remove package reference |
dotnet nuget why <package> | Show dependency graph for a package |
dotnet list package | List NuGet packages |
dotnet list package --include-transitive | Include transitive dependencies |
dotnet list reference --project <project> | List project-to-project references |
dotnet list package --outdated | Find packages with newer versions |
dotnet list package --vulnerable | Find packages with security issues |
dotnet outdated | (Third-party) Check outdated packages |
dotnet outdated -u | (Third-party) Auto-update packages |
dotnet tool search <term> | Search for dotnet tools |
dotnet tool update <id> | Update local tool to latest |
dotnet tool update --all | Update all local tools |
Search NuGet Packages
Find packages and check latest versions directly from CLI:
dotnet package search Serilog --take 5
dotnet package search Aspire.Hosting.AppHost --take 1
dotnet package search ModelContextProtocol --prerelease --take 3
dotnet package search Newtonsoft.Json --exact-match
dotnet package search Serilog --format json --take 3
Add and Update Packages
dotnet add package Serilog
dotnet add package Serilog -v 4.0.0
dotnet add package ModelContextProtocol --prerelease
dotnet add src/MyProject/MyProject.csproj package Serilog
dotnet add package Serilog
dotnet remove package Serilog
Note: dotnet add package both adds new packages and updates existing ones to the specified (or latest) version.
Manage Dotnet Tools
dotnet tool search dotnet-outdated --take 3
dotnet tool update cake.tool
dotnet tool update aspire.cli --prerelease
dotnet tool update --all
dotnet tool update -g dotnet-ef
Investigate Package Dependencies
To understand why a package is included in your project:
dotnet nuget why Newtonsoft.Json
dotnet nuget why path/to/Project.csproj Newtonsoft.Json
dotnet nuget why Newtonsoft.Json --framework net8.0
Output shows the complete dependency chain from your project to the package.
List NuGet Packages
dotnet list package
dotnet list package --include-transitive
dotnet list package --project path/to/Project.csproj
dotnet list package --format json
List Project References
dotnet list reference --project path/to/Project.csproj
Transitive Project References
No built-in command shows transitive project dependencies. To find if Project A depends on Project B transitively:
- Recursive approach: Run
dotnet list reference on each referenced project
- Parse .csproj files: Search for
<ProjectReference> elements recursively:
grep -r "ProjectReference" --include="*.csproj" .
Update Dependencies
Using dotnet outdated (Third-party)
If installed (dotnet tool install -g dotnet-outdated-tool):
dotnet outdated
dotnet outdated -u
dotnet outdated -u -inc PackageName
Using built-in commands
dotnet list package --outdated
dotnet list package --outdated --include-prerelease
Progressive Disclosure
For security auditing (vulnerable, deprecated, outdated packages), load references/security-audit.md.
References