dotnet-package-management
Manage NuGet packages using Central Package Management (CPM), dotnet CLI, and dotnet-outdated (command `dotnet outdated`) to inspect/update dependencies and diagnose restore issues. Never edit XML directly—prefer dotnet commands and dotnet-outdated.
Best use case
dotnet-package-management is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Manage NuGet packages using Central Package Management (CPM), dotnet CLI, and dotnet-outdated (command `dotnet outdated`) to inspect/update dependencies and diagnose restore issues. Never edit XML directly—prefer dotnet commands and dotnet-outdated.
Teams using dotnet-package-management should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/dotnet-package-management/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How dotnet-package-management Compares
| Feature / Agent | dotnet-package-management | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Manage NuGet packages using Central Package Management (CPM), dotnet CLI, and dotnet-outdated (command `dotnet outdated`) to inspect/update dependencies and diagnose restore issues. Never edit XML directly—prefer dotnet commands and dotnet-outdated.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# NuGet Package Management
## When to Use This Skill
Use this skill when:
- Adding, removing, or updating NuGet packages
- Setting up Central Package Management (CPM) for a solution
- Managing package versions across multiple projects
- Troubleshooting package conflicts, restore issues, or dependency drift
- Auditing outdated dependencies and applying safe upgrades with `dotnet outdated`
---
## Golden Rule: Never Edit XML Directly
**Always use `dotnet` CLI commands (and `dotnet outdated` where appropriate) to manage packages.** Never manually edit `.csproj` or `Directory.Packages.props`.
```bash
# DO: Use CLI commands
dotnet add package Newtonsoft.Json
dotnet remove package Newtonsoft.Json
dotnet list package --outdated
# DON'T: Edit XML directly
# <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
```
Why:
- CLI validates package exists and resolves versions
- Handles transitive dependencies correctly
- Updates lock files if present
- Avoids typos/malformed XML
- Works correctly with CPM
---
## Central Package Management (CPM)
CPM centralizes package versions in one file, eliminating version conflicts across projects.
### Enable CPM
Create `Directory.Packages.props` in solution root:
```xml
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Serilog" Version="4.0.0" />
<PackageVersion Include="xunit" Version="2.9.2" />
</ItemGroup>
</Project>
```
### Project Files with CPM
Projects reference packages **without versions**:
```xml
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Serilog" />
</ItemGroup>
</Project>
```
### Adding Packages with CPM
```bash
# Adds to Directory.Packages.props AND project file
dotnet add package Serilog.Sinks.Console
```
---
## dotnet-outdated (command: `dotnet outdated`)
`dotnet-outdated` is a .NET tool that:
- Finds outdated NuGet dependencies across a solution/project
- Can upgrade packages (optionally automatically)
- Helps surface dependency constraints that block upgrades
- Works well alongside CPM to keep versions consistent
### Install
Prefer a local tool manifest (reproducible), otherwise install globally.
```bash
# Local tool (recommended)
dotnet new tool-manifest
dotnet tool install dotnet-outdated-tool
# OR global tool
dotnet tool install --global dotnet-outdated-tool
```
Verify:
```bash
dotnet outdated --version
```
### Common Usage
Scan solution/project for outdated dependencies:
```bash
dotnet outdated
```
Scan a specific project:
```bash
dotnet outdated src/MyApp/MyApp.csproj
```
Include transitive dependencies (useful for “why can’t I upgrade X?” investigations):
```bash
dotnet outdated --include-transitive
```
Fail the build if outdated packages are found (CI gate):
```bash
dotnet outdated --fail-on-updates
```
Upgrade packages (interactive / apply upgrades):
```bash
# Upgrade (you can add additional flags as desired)
dotnet outdated --upgrade
```
> Notes for CPM:
> - With CPM enabled, upgrades should primarily flow through `Directory.Packages.props` (central versions).
> - Use `dotnet outdated` to *identify* and *apply* upgrades; then run `dotnet restore` and build/tests.
> - If you see upgrades being proposed at per-project level while using CPM, treat that as a signal to ensure the package is centrally versioned (and avoid manual XML edits).
### Troubleshooting with dotnet-outdated
When upgrades are blocked:
- Run with transitive included to see dependency chains:
```bash
dotnet outdated --include-transitive
```
Then:
- Check which package(s) constrain the version (often a direct dependency pins a lower range).
- Consider upgrading the constraining package first (or aligning versions via CPM).
---
## When NOT to Use CPM
Central Package Management isn't always the right choice:
### Legacy Projects
Migration can surface many conflicts at once. Consider incremental migration.
### Version Ranges
CPM expects exact versions (ranges aren’t supported in central management).
### Older Tooling
CPM requires newer SDK/NuGet/VS. If your team tooling is older, CPM can break builds.
### Multi-Repo Solutions
Each repo needs its own `Directory.Packages.props`.
---
## CLI Command Reference
### Adding Packages
```bash
dotnet add package Serilog
dotnet add package Serilog --version 4.0.0
dotnet add src/MyApp/MyApp.csproj package Serilog
```
### Removing Packages
```bash
dotnet remove package Serilog
dotnet remove src/MyApp/MyApp.csproj package Serilog
```
### Listing Packages
```bash
dotnet list package
dotnet list package --outdated
dotnet list package --include-transitive
dotnet list package --vulnerable
dotnet list package --deprecated
```
### Updating Packages
```bash
# Recommended: use dotnet-outdated
dotnet outdated
dotnet outdated --upgrade
# After upgrade
dotnet restore
```
### Restore and Clean
```bash
dotnet restore
dotnet nuget locals all --clear
dotnet restore --force
```
---
## Package Sources
```bash
dotnet nuget list source
```
```bash
dotnet nuget add source https://pkgs.dev.azure.com/myorg/_packaging/myfeed/nuget/v3/index.json \
--name MyFeed \
--username az \
--password $PAT \
--store-password-in-clear-text
```
---
## Troubleshooting
### Version Conflicts / Why is package X present?
```bash
dotnet list package --include-transitive
dotnet outdated --include-transitive
```
### Restore Failures
```bash
dotnet nuget locals all --clear
dotnet restore --verbosity detailed
```
### Lock Files (Reproducible Builds)
```xml
<!-- Directory.Build.props -->
<PropertyGroup>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
</PropertyGroup>
```
Commit `packages.lock.json` files.
---
## Anti-Patterns
- Editing XML directly
- Inline versions when using CPM
- Mixing version management (some centralized, some inline)
- Letting related packages drift to different versions (use shared version variables)
---
## Quick Reference
| Task | Command |
|------|---------|
| Add package | `dotnet add package <name>` |
| Remove package | `dotnet remove package <name>` |
| List packages | `dotnet list package` |
| Outdated (built-in view) | `dotnet list package --outdated` |
| Outdated (richer tooling) | `dotnet outdated` |
| Upgrade deps | `dotnet outdated --upgrade` |
| CI gate on updates | `dotnet outdated --fail-on-updates` |
| Restore | `dotnet restore` |
| Clear cache | `dotnet nuget locals all --clear` |
---
## Resources
- Central Package Management: https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management
- dotnet CLI reference: https://learn.microsoft.com/en-us/dotnet/core/tools/
- NuGet.config reference: https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file
- dotnet-outdated README: https://github.com/dotnet-outdated/dotnet-outdated/blob/master/README.mdRelated Skills
dotnet-testing-nsubstitute-mocking
Specialized skill for creating test doubles (Mock, Stub, Spy) using NSubstitute. Use when isolating external dependencies, simulating interface behavior, and verifying method calls. Covers complete guidance on Substitute.For, Returns, Received, Throws, etc.
xunit
Writes unit tests with xUnit framework across 30 test projects. Use when: writing new tests, adding test coverage, creating integration tests, setting up test fixtures, or debugging test failures.
visual-explainer
Generate beautiful, self-contained HTML pages that visually explain systems, code changes, plans, and data. Use when the user asks for a diagram, architecture overview, diff review, plan review, project recap, comparison table, or any visual explanation of technical concepts. Also use proactively when you are about to render a complex ASCII table (4+ rows or 3+ columns) — present it as a styled HTML page instead.
skill-creator
Guide for creating high-quality Agent Skills following the open standard (agentskills.io). Use this when asked to create or update a skill, write a SKILL.md file, convert custom instructions or chatmodes into portable skills, or design specialized AI agent capabilities.
review-code
Perform comprehensive csharp/dotnet code reviews focusing on clean code, security, testing, performance, and documentation
requirements-engineering
Transform vague feature ideas into lightweight, testable requirements using user stories and short acceptance criteria. Use when clarifying scope, defining expected behavior, capturing edge cases, and producing decision-ready requirements with Definition of Ready checks.
playwright-skill
Complete browser automation with Playwright. Auto-detects dev servers, writes clean test scripts to /.tmp. Test pages, fill forms, take screenshots, check responsive design, validate UX, test login flows, check links, automate any browser task. Use when user wants to test websites, automate browser interactions, validate web functionality, or perform any browser-based testing.
mermaid-diagrams
Comprehensive guide for creating software diagrams using Mermaid syntax. Use when users need to create, visualize, or document software through diagrams including class diagrams (domain modeling, object-oriented design), sequence diagrams (application flows, API interactions, code execution), flowcharts (processes, algorithms, user journeys), entity relationship diagrams (database schemas), C4 architecture diagrams (system context, containers, components), state diagrams, git graphs, pie charts, gantt charts, or any other diagram type. Triggers include requests to "diagram", "visualize", "model", "map out", "show the flow", or when explaining system architecture, database design, code structure, or user/application flows.
grill-me
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
git-commit
Execute git commit with conventional commit message analysis, intelligent staging, and message generation. Use when user asks to commit changes, create a git commit, or mentions "/commit". Supports: (1) Auto-detecting type and scope from changes, (2) Generating conventional commit messages from diff, (3) Interactive commit with optional type/scope/description overrides, (4) Intelligent file staging for logical grouping
frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
find-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.