[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.
Framework and package behavior often explains local code, but the source is outside the repo.
The model can inspect external definitions and package usage evidence instead of guessing from API names.
Try it locally in the Glider playground
| Name | Type | Required | Description |
|---|---|---|---|
| packageId | string | Yes | NuGet package ID to rewrite. |
| targetVersion | string | Yes | Target version to write into matching declarations. |
| projectName | string | No | Optional project name filter. |
| promoteToCentralPackageManagement | boolean | No | When true, promotes matching SDK-style PackageReference declarations into Directory.Packages.props and removes inline version declarations. Legacy package styles stay unchanged in this mode. |
| applyChanges | boolean | No | Apply changes to disk. Default is true; pass false for a preview. |
| includeDiff | boolean | No | Include a unified diff in the response. Default is true. |
| maxDiffChars | number | No | Maximum unified diff characters to return. Default is 50000. Use 0 for unlimited. |
| includePerFileDiff | boolean | No | Include per-file diffs in changedFiles. Default is true. |
| pathStyle | string | No | Path style: 'absolute' (default) or 'relative' (to solution root). |
Preview version alignment for one package
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "consolidate_package_version",
"arguments": {
"packageId": "Newtonsoft.Json",
"targetVersion": "13.0.4",
"applyChanges": false
}
}
}{
"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
{
"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
}
}
}{
"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
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "consolidate_package_version",
"arguments": {
"packageId": "Newtonsoft.Json",
"targetVersion": "13.0.4",
"projectName": "MyProject"
}
}
}{
"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
}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.