Get the FREE Ultimate OpenClaw Setup Guide →

Dotnet Dependency

Scanned
npx machina-cli add skill NikiforovAll/claude-code-rules/dotnet-dependency --openclaw
Files (1)
SKILL.md
6.7 KB

.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

CommandPurpose
dotnet package search <term>Search NuGet for packages
dotnet package search <name> --exact-matchList 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 packageList NuGet packages
dotnet list package --include-transitiveInclude transitive dependencies
dotnet list reference --project <project>List project-to-project references
dotnet list package --outdatedFind packages with newer versions
dotnet list package --vulnerableFind 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 --allUpdate all local tools

Search NuGet Packages

Find packages and check latest versions directly from CLI:

# Search for packages by keyword
dotnet package search Serilog --take 5

# Find latest version of a specific package
dotnet package search Aspire.Hosting.AppHost --take 1

# Include prerelease versions
dotnet package search ModelContextProtocol --prerelease --take 3

# List ALL available versions of a package (version history)
dotnet package search Newtonsoft.Json --exact-match

# JSON output for scripting
dotnet package search Serilog --format json --take 3

Add and Update Packages

# Add package (installs latest stable version)
dotnet add package Serilog

# Add specific version
dotnet add package Serilog -v 4.0.0

# Add prerelease version
dotnet add package ModelContextProtocol --prerelease

# Add to specific project
dotnet add src/MyProject/MyProject.csproj package Serilog

# Update existing package to latest (same command as add)
dotnet add package Serilog

# Remove package
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

# Search for tools
dotnet tool search dotnet-outdated --take 3

# Update a local tool (from manifest)
dotnet tool update cake.tool

# Update with prerelease
dotnet tool update aspire.cli --prerelease

# Update all local tools
dotnet tool update --all

# Update global tool
dotnet tool update -g dotnet-ef

Investigate Package Dependencies

To understand why a package is included in your project:

# Why is this package included?
dotnet nuget why Newtonsoft.Json

# For a specific project
dotnet nuget why path/to/Project.csproj Newtonsoft.Json

# For a specific framework
dotnet nuget why Newtonsoft.Json --framework net8.0

Output shows the complete dependency chain from your project to the package.

List NuGet Packages

# Direct dependencies only
dotnet list package

# Include transitive (indirect) dependencies
dotnet list package --include-transitive

# For a specific project
dotnet list package --project path/to/Project.csproj

# JSON output for scripting
dotnet list package --format json

List Project References

# List project-to-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:

  1. Recursive approach: Run dotnet list reference on each referenced project
  2. Parse .csproj files: Search for <ProjectReference> elements recursively:
# Find all ProjectReference elements
grep -r "ProjectReference" --include="*.csproj" .

Update Dependencies

Using dotnet outdated (Third-party)

If installed (dotnet tool install -g dotnet-outdated-tool):

# Check for outdated packages
dotnet outdated

# Auto-update to latest versions
dotnet outdated -u

# Update only specific packages
dotnet outdated -u -inc PackageName

Using built-in commands

# Check for outdated packages
dotnet list package --outdated

# Include prerelease versions
dotnet list package --outdated --include-prerelease

Progressive Disclosure

For security auditing (vulnerable, deprecated, outdated packages), load references/security-audit.md.

References

Source

git clone https://github.com/NikiforovAll/claude-code-rules/blob/main/plugins/handbook-dotnet/skills/dotnet-dependency/SKILL.mdView on GitHub

Overview

This skill helps you investigate and manage .NET project dependencies using the dotnet CLI. It covers discovering packages, understanding why they're included, auditing for outdated or vulnerable packages, and tracing transitive dependencies.

How This Skill Works

Leverage built-in dotnet commands such as dotnet package search, dotnet list package, dotnet nuget why, and dotnet add/remove package to inspect, query, and modify package references. It also includes managing dotnet tools and listing project-to-project references as needed.

When to Use It

  • You need to search NuGet for packages or check latest versions.
  • You want to add, update, or remove a package reference.
  • You need to understand why a specific NuGet package is included in the project.
  • You want to list all dependencies, including transitive ones.
  • You must identify outdated or vulnerable dependencies and audit security.

Quick Start

  1. Step 1: Open a terminal in the project root
  2. Step 2: Find packages or dependencies with dotnet package search or dotnet list package
  3. Step 3: Update or adjust references with dotnet add package <id> or dotnet remove package <id>

Best Practices

  • Search for packages with dotnet package search and review versions with take or exact-match when needed.
  • List dependencies with dotnet list package and include-transitive to see all references.
  • Use dotnet nuget why to understand the dependency graph for a package.
  • Prefer specifying exact versions when upgrading to avoid breaking changes.
  • Regularly run dotnet list package --outdated and --vulnerable to identify issues and plan fixes.

Example Use Cases

  • dotnet package search Serilog --take 5
  • dotnet list package
  • dotnet nuget why Serilog
  • dotnet list package --outdated
  • dotnet list package --vulnerable

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers