跳到正文
Skillpedia
API 与服务器(后端)40k · #7310

nuget-manager

它能做什么

这个代理可以帮你管理 .NET 编程项目中的代码包。它会使用正确的工具,确保你安全地添加、删除或更新包。

适用场景

  • ✓当你需要添加一个新的代码包时。
  • ✓当你需要删除一个不再使用的包时。
  • ✓当你需要把某个包更新到新版本时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/nuget-manager/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/nuget-manager/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请把 Newtonsoft.Json 包添加到 MyProject 项目中。”

每周 5 个新技能,1 分钟读完。

工作原理

它会使用特定的 .NET 命令来管理包,避免手动编辑可能破坏项目的文件。更新时,它会检查新版本是否存在,并还原项目,确保一切正常运行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

NuGet Manager

Overview

This skill ensures consistent and safe management of NuGet packages across .NET projects. It prioritizes using the dotnet CLI to maintain project integrity and enforces a strict verification and restoration workflow for version updates.

Prerequisites

  • .NET SDK installed (typically .NET 8.0 SDK or later, or a version compatible with the target solution).
  • dotnet CLI available on your PATH.
  • jq (JSON processor) OR PowerShell (for version verification using dotnet package search).

Core Rules

  1. NEVER directly edit .csproj, .props, or Directory.Packages.props files to add or remove packages. Always use dotnet add package and dotnet remove package commands.
  2. DIRECT EDITING is ONLY permitted for changing versions of existing packages.
  3. VERSION UPDATES must follow the mandatory workflow:
    • Verify the target version exists on NuGet.
    • Determine if versions are managed per-project (.csproj) or centrally (Directory.Packages.props).
    • Update the version string in the appropriate file.
    • Immediately run dotnet restore to verify compatibility.

Workflows

Adding a Package

Use dotnet add [<PROJECT>] package <PACKAGE_NAME> [--version <VERSION>]. Example: dotnet add src/MyProject/MyProject.csproj package Newtonsoft.Json

Removing a Package

Use dotnet remove [<PROJECT>] package <PACKAGE_NAME>. Example: dotnet remove src/MyProject/MyProject.csproj package Newtonsoft.Json

Updating Package Versions

When updating a version, follow these steps:

  1. Verify Version Existence: Check if the version exists using the dotnet package search command with exact match and JSON formatting. Using jq: dotnet package search <PACKAGE_NAME> --exact-match --format json | jq -e '.searchResult[].packages[] | select(.version == "<VERSION>")' Using PowerShell: (dotnet package search <PACKAGE_NAME> --exact-match --format json | ConvertFrom-Json).searchResult.packages | Where-Object { $_.version -eq "<VERSION>" }

  2. Determine Version Management:

    • Search for Directory.Packages.props in the solution root. If present, versions should be managed there via <PackageVersion Include="Package.Name" Version="1.2.3" />.
    • If absent, check individual .csproj files for <PackageReference Include="Package.Name" Version="1.2.3" />.
  3. Apply Changes: Modify the identified file with the new version string.

  4. Verify Stability: Run dotnet restore on the project or solution. If errors occur, revert the change and investigate.

Examples

User: "Add Serilog to the WebApi project"

Action: Execute dotnet add src/WebApi/WebApi.csproj package Serilog.

User: "Update Newtonsoft.Json to 13.0.3 in the whole solution"

Action:

  1. Verify 13.0.3 exists: dotnet package search Newtonsoft.Json --exact-match --format json (and parse output to confirm "13.0.3" is present).
  2. Find where it's defined (e.g., Directory.Packages.props).
  3. Edit the file to update the version.
  4. Run dotnet restore.
常见问题

我能直接编辑项目文件来添加或删除包吗?

不能。添加或删除包时,必须使用 `dotnet add package` 和 `dotnet remove package` 命令。只有更新版本时才允许直接编辑。

如果更新包后出现错误怎么办?

如果更新后出现错误,代理会撤销这次改动,之后你需要排查问题。

它怎么知道该在哪里更新包的版本?

它会检查版本是集中在一个文件(`Directory.Packages.props`)里管理,还是分散在各个项目文件(`.csproj`)中,然后把更新应用到正确的位置。

详情

作者的原始描述

Manage NuGet packages in .NET projects/solutions. Use this skill when adding, removing, or updating NuGet package versions. It enforces using `dotnet` CLI for package management and provides strict procedures for direct file edits only when updating versions.

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7310
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能