lr.Dotnet.NugetUpdateTool 2026.9.24.154

lr-nuget-update

NuGet

A command-line tool to keep your NuGet packages up to date when using Central Package Management (Directory.Packages.props). It scans your solution, checks for newer versions, and updates your centralized configuration automatically.

Usage

Run it directly with dnx:

dnx -y lr.Dotnet.NugetUpdateTool [directory] [--allow-major] [--filter <globs>] [--config-file <path>] [--group-by-repository] [--allow-downgrade] [--dedup]

Examples

Update packages in the current directory:

dnx -y lr.Dotnet.NugetUpdateTool

Allow major version updates:

dnx -y lr.Dotnet.NugetUpdateTool --allow-major

Update packages in a specific project or solution folder:

dnx -y lr.Dotnet.NugetUpdateTool ./src/MyProject

Only touch one package family, and move it as a unit:

dnx -y lr.Dotnet.NugetUpdateTool --filter 'HDH.Shared.*' --group-by-repository --allow-major

Use exactly one NuGet config file instead of the discovered hierarchy:

dnx -y lr.Dotnet.NugetUpdateTool --config-file "$HOME/.nuget/NuGet/NuGet.Config"

Remove duplicate PackageVersion entries (no version update):

dnx -y lr.Dotnet.NugetUpdateTool --dedup

Options

Option Effect
--allow-major Accept versions of a different major than the current pin.
--filter <globs> Comma-separated package id patterns (Prefix* or exact id); only matching packages are touched.
--config-file <path> Load exactly this NuGet config file. Without it the nuget.config hierarchy plus the user-level and machine-wide configuration are read.
--group-by-repository Packages whose currently pinned version carries the same nuspec <repository url="…"> form a group and move together to the newest version that is available for every member. If no such version exists the group is left untouched and a warning names the members lacking the newest candidate. Packages without a repository url are updated individually.
--allow-downgrade Drop the "newer than the current pin" requirement, so a group can settle on a common version below one member's pin (a member bumped ahead by hand, or a switch between release channels). A package already at the newest available version stays where it is.
--dedup Standalone action: remove duplicate <PackageVersion> entries from Directory.Packages.props, keeping the highest version of each id, then stop. Nothing is updated. A normal run never touches duplicates; it prints a loud warning instead, because NuGet resolves the first entry per id and can silently pin an old version.

How it works

The tool follows a smart process to ensure your solution is updated safely and correctly:

  1. Solution Discovery It finds your .sln or .slnx file. If not found in the current directory, it searches up the folder tree (up to 10 levels) until it locates one.
  2. Project & Package Scanning It identifies all .csproj files within the solution and extracts all used NuGet packages.
  3. Version Checking It queries your configured NuGet sources (including private ones from your nuget.config) for the latest available versions.
  4. Safe Updates By default, it only updates to the latest version within the same major version. This prevents breaking changes while ensuring you get the latest bug fixes and minor improvements. To allow major version updates, use the --allow-major flag. Prerelease versions are only considered when the current pin is itself a prerelease. With --group-by-repository, packages published from one repository (same nuspec repository url) are treated as one release train and always move to one common version, which avoids partial bumps that fail restore (NU1109).
  5. Centralized Management
    • It writes updates directly to Directory.Packages.props.
    • If the file doesn't exist, it creates one and enables Central Package Management for you.
    • It ensures Directory.Packages.props is added to your "Solution Items" folder so it's easily accessible in your IDE.

Good to know

  • CPM Support: This tool is specifically designed for projects using Central Package Management.
  • Transitive Pinning: When creating a new Directory.Packages.props, it enables CentralPackageTransitivePinningEnabled by default.
  • Safety: As with any tool that modifies project files, it's recommended to run this on a clean git state so you can easily undo the changes if needed.
  • Requirements: Requires .NET 10.0 or later.

Installation

If you prefer to have it installed globally on your machine:

dotnet tool install -g lr.Dotnet.NugetUpdateTool

Usage after installation:

lr-nuget-update [directory] [--allow-major] [--filter <globs>] [--config-file <path>] [--group-by-repository] [--allow-downgrade] [--dedup]

This package has no dependencies.

Version Downloads Last updated
2026.9.25.17 3 09/25/2026
2026.9.24.2201 3 09/24/2026
2026.9.24.154 3 09/24/2026
2026.9.24.56 3 09/24/2026
2026.7.15.600 5 07/15/2026
2026.7.4.1248 5 07/04/2026
2026.3.24.1737 9 03/24/2026
2026.3.24.1722 8 03/24/2026