consolidate_package_version

[external]

Rewrites one package to a target version across supported PackageReference, packages.config, and legacy package-folder HintPath declarations. Set applyChanges=false for a preview diff.

Why this tool exists

Framework and package behavior often explains local code, but the source is outside the repo.

How it helps the agent

The model can inspect external definitions and package usage evidence instead of guessing from API names.

Try it locally in the Glider playground

Parameters

NameTypeRequiredDescription
packageIdstringYesNuGet package ID to rewrite.
targetVersionstringYesTarget version to write into matching declarations.
projectNamestringNoOptional project name filter.
promoteToCentralPackageManagementbooleanNoWhen true, promotes matching SDK-style PackageReference declarations into Directory.Packages.props and removes inline version declarations. Legacy package styles stay unchanged in this mode.
applyChangesbooleanNoApply changes to disk. Default is true; pass false for a preview.
includeDiffbooleanNoInclude a unified diff in the response. Default is true.
maxDiffCharsnumberNoMaximum unified diff characters to return. Default is 50000. Use 0 for unlimited.
includePerFileDiffbooleanNoInclude per-file diffs in changedFiles. Default is true.
pathStylestringNoPath style: 'absolute' (default) or 'relative' (to solution root).

Examples

Preview version alignment for one package

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "applyChanges": false
    }
  }
}
Response
{
  "success": true,
  "data": {
    "packageId": "Newtonsoft.Json",
    "targetVersion": "13.0.4",
    "promoteToCentralPackageManagement": true,
    "preview": false,
    "applied": true,
    "changed": true,
    "centralPackageFilePath": "/path/to/Directory.Packages.props",
    "filesChanged": 2,
    "declarationCount": 3,
    "changedFiles": [
      {
        "filePath": "/path/to/MyProject.csproj",
        "changeCount": 2
      },
      {
        "filePath": "/path/to/Directory.Packages.props",
        "changeCount": 1
      }
    ]
  },
  "error": null
}

Preview SDK-style promotion into central package management

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "promoteToCentralPackageManagement": true,
      "applyChanges": false
    }
  }
}
Response
{
  "success": true,
  "data": {
    "packageId": "Newtonsoft.Json",
    "targetVersion": "13.0.4",
    "promoteToCentralPackageManagement": true,
    "preview": false,
    "applied": true,
    "changed": true,
    "centralPackageFilePath": "/path/to/Directory.Packages.props",
    "filesChanged": 2,
    "declarationCount": 3,
    "changedFiles": [
      {
        "filePath": "/path/to/MyProject.csproj",
        "changeCount": 2
      },
      {
        "filePath": "/path/to/Directory.Packages.props",
        "changeCount": 1
      }
    ]
  },
  "error": null
}

Rewrite a scoped package version

Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "consolidate_package_version",
    "arguments": {
      "packageId": "Newtonsoft.Json",
      "targetVersion": "13.0.4",
      "projectName": "MyProject"
    }
  }
}
Response
{
  "success": true,
  "data": {
    "packageId": "Newtonsoft.Json",
    "targetVersion": "13.0.4",
    "promoteToCentralPackageManagement": true,
    "preview": false,
    "applied": true,
    "changed": true,
    "centralPackageFilePath": "/path/to/Directory.Packages.props",
    "filesChanged": 2,
    "declarationCount": 3,
    "changedFiles": [
      {
        "filePath": "/path/to/MyProject.csproj",
        "changeCount": 2
      },
      {
        "filePath": "/path/to/Directory.Packages.props",
        "changeCount": 1
      }
    ]
  },
  "error": null
}

Response Notes

Returns per-file diffs for supported package declaration rewrites. A preview (applyChanges=false) leads with preview:true and reports wouldChange/filesThatWouldChange instead of the past-tense counts below.

↑/↓ NavigateEnter OpenSpace Expand