ln-822-nuget-upgrader

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Paths: File paths (
shared/
,
references/
,
../ln-*
) are relative to skills repo root. If not found at CWD, locate this SKILL.md directory and go up one level for repo root.
路径: 文件路径(
shared/
references/
../ln-*
)是相对于技能仓库根目录的。如果在当前工作目录(CWD)中未找到,请定位此SKILL.md所在目录,然后向上一级目录即为仓库根目录。

ln-822-nuget-upgrader

ln-822-nuget-upgrader

Type: L3 Worker Category: 8XX Optimization Parent: ln-820-dependency-optimization-coordinator
Upgrades .NET NuGet packages with automatic breaking change detection and migration.

类型: L3 Worker 分类: 8XX 优化 父级: ln-820-dependency-optimization-coordinator
升级.NET NuGet包,具备自动重大变更检测与迁移功能。

Overview

概述

AspectDetails
InputSolution/project path
OutputUpdated .csproj files, migration report
Supports.NET 6, 7, 8, 9, 10

方面详情
输入解决方案/项目路径
输出更新后的.csproj文件、迁移报告
支持版本.NET 6、7、8、9、10

Workflow

工作流程

Phases: Pre-flight → Find Projects → Security Audit → Check Outdated → Identify Breaking → Apply Upgrades → Restore & Build → Report

阶段: 预检 → 查找项目 → 安全审计 → 检查过时包 → 识别重大变更 → 应用升级 → 还原与构建 → 生成报告

Phase 0: Pre-flight Checks

阶段0:预检

CheckRequiredAction if Missing
.csproj file(s)YesBlock upgrade
.sln fileNoUse csproj discovery instead
Git clean stateYesBlock (need clean baseline for revert)
Workers assume coordinator (ln-820) already verified git state and created backup.
检查项是否必需缺失时操作
.csproj文件阻止升级
.sln文件改为自动发现.csproj
Git干净状态阻止升级(需要干净的基线以便回滚)
工作器(Worker)假设协调器(ln-820)已验证Git状态并创建备份。

Worktree & Branch Isolation

工作树与分支隔离

MANDATORY READ: Load
shared/references/git_worktree_fallback.md
— use ln-822 row.

必读: 加载
shared/references/git_worktree_fallback.md
— 使用ln-822相关内容。

Phase 1: Find Projects

阶段1:查找项目

Discovery Methods

发现方式

MethodCommand
Find .csproj
Get-ChildItem -Recurse -Filter *.csproj
From solution
dotnet sln list

方式命令
查找.csproj
Get-ChildItem -Recurse -Filter *.csproj
从解决方案获取
dotnet sln list

Phase 2: Security Audit

阶段2:安全审计

Commands

命令

CheckCommand
Vulnerable packages
dotnet list package --vulnerable
Outdated packages
dotnet list package --outdated
检查项命令
存在漏洞的包
dotnet list package --vulnerable
过时的包
dotnet list package --outdated

Actions

操作

SeverityAction
CriticalBlock upgrade, report
HighWarn, continue
Moderate/LowLog only

严重程度操作
严重阻止升级并生成报告
发出警告并继续
中/低仅记录日志

Phase 3: Check Outdated

阶段3:检查过时包

Using dotnet-outdated

使用dotnet-outdated

StepCommand
Install tool
dotnet tool install --global dotnet-outdated-tool
Check
dotnet outdated --output json

步骤命令
安装工具
dotnet tool install --global dotnet-outdated-tool
检查
dotnet outdated --output json

Phase 4: Identify Breaking Changes

阶段4:识别重大变更

Detection

检测方式

  1. Compare current vs latest major versions
  2. Check breaking_changes_patterns.md
  3. Use MCP tools (see below) for migration guides
  1. 对比当前版本与最新主版本
  2. 查看breaking_changes_patterns.md
  3. 使用MCP工具(如下所示)查找迁移指南

Common Breaking Changes

常见重大变更

PackageBreaking VersionKey Changes
Microsoft.EntityFrameworkCore8 → 9Query changes, migration format
Serilog.AspNetCore7 → 8Configuration format
Swashbuckle.AspNetCore6 → 7Minimal API support

变更版本主要变更
Microsoft.EntityFrameworkCore8 → 9查询逻辑变更、迁移格式变更
Serilog.AspNetCore7 → 8配置格式变更
Swashbuckle.AspNetCore6 → 7Minimal API支持

MCP Tools for Migration Search

用于迁移搜索的MCP工具

Priority Order (Fallback Strategy)

优先级顺序(回退策略)

PriorityToolWhen to Use
1mcp__context7__query-docsFirst choice for library docs
2mcp__Ref__ref_search_documentationOfficial Microsoft docs
3WebSearchLatest info, community solutions
优先级工具使用场景
1mcp__context7__query-docs首选:查找库文档
2mcp__Ref__ref_search_documentation官方Microsoft文档
3WebSearch获取最新信息、社区解决方案

Context7 Usage

Context7使用方法

StepToolParameters
1. Find librarymcp__context7__resolve-library-idlibraryName: "EntityFrameworkCore"
2. Query docsmcp__context7__query-docsquery: "EF Core 8 to 9 migration breaking changes"
步骤工具参数
1. 查找库mcp__context7__resolve-library-idlibraryName: "EntityFrameworkCore"
2. 查询文档mcp__context7__query-docsquery: "EF Core 8 to 9 migration breaking changes"

MCP Ref Usage

MCP Ref使用方法

ActionToolQuery Example
Searchmcp__Ref__ref_search_documentation"dotnet EntityFrameworkCore 9 migration guide"
Readmcp__Ref__ref_read_urlURL from search results
操作工具查询示例
搜索mcp__Ref__ref_search_documentation"dotnet EntityFrameworkCore 9 migration guide"
读取mcp__Ref__ref_read_url搜索结果中的URL

WebSearch Fallback

WebSearch回退方案

Use when Context7/Ref return no results:
  • "<package> .NET <version> breaking changes migration"
  • "<error code> <package> fix"

当Context7/Ref无结果时使用:
  • "<包名> .NET <版本> breaking changes migration"
  • "<错误代码> <包名> fix"

Phase 5: Apply Upgrades

阶段5:应用升级

Priority Order

优先级顺序

PriorityPackage Type
1SDK/Runtime (Microsoft.NET.Sdk)
2Framework (Microsoft.AspNetCore.*)
3EF Core (affects migrations)
4Logging (Serilog.*)
5Other packages
优先级包类型
1SDK/运行时(Microsoft.NET.Sdk)
2框架(Microsoft.AspNetCore.*)
3EF Core(影响迁移)
4日志组件(Serilog.*)
5其他包

Commands

命令

ActionCommand
Update specific
dotnet add package <name> --version <ver>
Update all
dotnet outdated --upgrade

操作命令
更新特定包
dotnet add package <name> --version <ver>
更新所有包
dotnet outdated --upgrade

Phase 6: Restore & Build

阶段6:还原与构建

Commands

命令

StepCommand
Restore
dotnet restore
Build
dotnet build --configuration Release
Test
dotnet test
步骤命令
还原
dotnet restore
构建
dotnet build --configuration Release
测试
dotnet test

On Failure

失败处理

  1. Identify failing package from error
  2. Search Context7/Ref for migration guide
  3. If unresolved: rollback package, continue

  1. 从错误信息中定位失败的包
  2. 使用Context7/Ref查找迁移指南
  3. 若仍无法解决:回滚该包,继续执行其他升级

Phase 7: Report Results

阶段7:生成结果报告

Report Schema

报告格式

FieldDescription
solutionSolution path
projects[]Updated projects
durationTotal time
upgrades[]Applied upgrades
buildVerificationPASSED or FAILED
testResultsX passed, Y failed

字段描述
solution解决方案路径
projects[]已更新的项目
duration总耗时
upgrades[]已应用的升级
buildVerification通过(PASSED)或失败(FAILED)
testResultsX个通过,Y个失败

Configuration

配置

yaml
Options:
  # Upgrade scope
  upgradeType: major          # major | minor | patch

  # Security
  auditLevel: high
  minimumReleaseAge: 14

  # .NET specific
  includePrerelease: false
  targetFramework: net10.0

  # Verification
  runTests: true
  runBuild: true

yaml
Options:
  # 升级范围
  upgradeType: major          # major | minor | patch

  # 安全设置
  auditLevel: high
  minimumReleaseAge: 14

  # .NET特定配置
  includePrerelease: false
  targetFramework: net10.0

  # 验证设置
  runTests: true
  runBuild: true

Error Handling

错误处理

ErrorCauseSolution
CS0246Missing typeSearch for replacement API
NU1605Downgrade detectedCheck package constraints
Build failBreaking changeApply migration via Context7

错误原因解决方案
CS0246类型缺失查找替代API
NU1605检测到降级检查包约束
构建失败重大变更通过Context7应用迁移方案

References

参考文档

  • breaking_changes_patterns.md
  • dotnet_version_matrix.md

  • breaking_changes_patterns.md
  • dotnet_version_matrix.md

Definition of Done

完成标准

  • All .csproj files discovered (via solution or recursive scan)
  • Security audit completed (
    dotnet list package --vulnerable
    )
  • Outdated packages identified via dotnet-outdated
  • Breaking changes detected via breaking_changes_patterns.md and MCP tools
  • Upgrades applied in priority order (SDK > Framework > EF Core > other)
  • dotnet restore
    ,
    dotnet build
    ,
    dotnet test
    all pass
  • Report returned with projects updated, upgrades applied, and build/test status

Version: 1.1.0 Last Updated: 2026-01-10
  • 所有.csproj文件已被发现(通过解决方案或递归扫描)
  • 安全审计已完成(执行
    dotnet list package --vulnerable
  • 通过dotnet-outdated识别出所有过时包
  • 通过breaking_changes_patterns.md和MCP工具检测到重大变更
  • 已按优先级顺序应用升级(SDK > 框架 > EF Core > 其他)
  • dotnet restore
    dotnet build
    dotnet test
    全部通过
  • 已返回包含更新项目、已应用升级、构建/测试状态的报告

版本: 1.1.0 最后更新时间: 2026-01-10