Samayas.Tools.ProjectsNugetUpdater
1.1.0
Prefix Reserved
dotnet tool install --global Samayas.Tools.ProjectsNugetUpdater --version 1.1.0
dotnet new tool-manifest
dotnet tool install --local Samayas.Tools.ProjectsNugetUpdater --version 1.1.0
#tool dotnet:?package=Samayas.Tools.ProjectsNugetUpdater&version=1.1.0
nuke :add-package Samayas.Tools.ProjectsNugetUpdater --version 1.1.0
Samayas Tools Projects Nuget Updater
A .NET global tool that automates NuGet package updates across your solution with built-in git workflow support, build/test validation, and secure PAT configuration for private feeds.
Video Usage Description
Here you can find a video describing how to use this Tools Projects Nuget Updater https://l.samayas.eu/
Features
Automated Package Updates - Scans and updates all NuGet packages in your solution Git Integration - Automatically creates branches, commits, and pushes changes Build & Test Validation - Runs builds and tests before and after updates Private Feed Support - Secure PAT configuration for Azure DevOps and private NuGet feeds Project Filtering - Target specific projects with wildcard or explicit lists Package Exclusion - Exclude specific packages from being updated Flexible Configuration - Extensive command-line options to customize behavior Safe Updates - Pre/post validation ensures your solution remains functional
Installation
Global Tool Installation
dotnet tool install --global Samayas.Tools.ProjectsNugetUpdater
Update Existing Installation
dotnet tool update --global Samayas.Tools.ProjectsNugetUpdater
Quick Start
Basic Usage
projects-nuget-updater C:\Projects\MySolution
With Private NuGet Feeds
First, configure your Personal Access Token (PAT):
A Personal Access Token (PAT) needs to have Packaging (Read) access on an Azure Devops Feed.
Interactive mode
projects-nuget-updater setup-pat
Or provide credentials directly
projects-nuget-updater setup-pat --source="Azure DevOps" --token=your_pat_token
Then run the updater:
projects-nuget-updater C:\Projects\MySolution
Command Reference
Main Command
Arguments:
<solution-directory>- Required. Path to the .NET solution directory
PAT Setup Command
projects-nuget-updater setup-pat [--source=<name>] [--token=<pat>]
Configure authentication for private NuGet feeds. Can be run interactively or with command-line parameters.
Options
Git Operations
| Option | Default | Description |
|---|---|---|
--usegit=<bool> |
true |
Enable/disable git operations |
--gitcommit=<bool> |
true |
Commit changes to git |
--gitpush=<bool> |
true |
Push changes to remote repository |
--gitbranchname=<name> |
feature/update-packages |
Name of the git branch to create |
--gitbranchcreate=<bool> |
true |
Create a new git branch |
Build & Test
| Option | Default | Description |
|---|---|---|
--prebuild=<bool> |
true |
Run build before updates |
--pretest=<bool> |
true |
Run tests before updates |
--postbuild=<bool> |
true |
Run build after updates |
--posttest=<bool> |
true |
Run tests after updates |
--buildconfiguration=<config> |
Release |
Build configuration (Debug/Release) |
Configuration
| Option | Default | Description |
|---|---|---|
--nugetconfigfile=<file> |
nuget.config |
NuGet configuration file name |
--includePreRelease=<bool> |
false |
Update to prereleases or not. When false pre-release are ignored |
Project Filtering
| Option | Default | Description |
|---|---|---|
--filteronprojectfiles=<pattern> |
(empty) | Filter projects by wildcard or semicolon-separated list |
--excludeprojectfiles=<list> |
(empty) | Exclude specific projects (semicolon-separated list) |
Package Filtering
| Option | Default | Description |
|---|---|---|
--excludepackagesforupdate=<list> |
(empty) | Exclude specific packages from update (semicolon-separated list) |
PAT Setup Options
| Option | Description |
|---|---|
--source=<name> |
Source name for PAT configuration |
--token=<pat> |
Personal Access Token |
Boolean Values
Boolean options accept the following formats:
true,false1,0yes,no
Examples
Update All Projects
projects-nuget-updater C:\Projects\MySolution
Update Specific Projects Using Wildcards
Update only projects matching pattern
projects-nuget-updater C:\Projects\MySolution --filteronprojectfiles="MyApp.*.csproj"
Update Specific Projects Using List
Update only specific projects
projects-nuget-updater C:\Projects\MySolution --filteronprojectfiles="MyApp.Core.csproj;MyApp.Api.csproj"
Update All Projects Except Some
Update all projects except test and benchmark projects
projects-nuget-updater C:\Projects\MySolution --excludeprojectfiles="MyApp.Tests.csproj;MyApp.Benchmarks.csproj"
Combine Filter and Exclusion
Update all MyApp projects except tests
projects-nuget-updater C:\Projects\MySolution --filteronprojectfiles="MyApp.*.csproj" --excludeprojectfiles="MyApp.Tests.csproj"
Update Without Git Operations
projects-nuget-updater C:\Projects\MySolution --usegit=false
Skip Build and Test Validation
projects-nuget-updater C:\Projects\MySolution --prebuild=false --pretest=false --postbuild=false --posttest=false
Use Debug Configuration
projects-nuget-updater C:\Projects\MySolution --buildconfiguration=Debug
Custom Git Branch Name
projects-nuget-updater C:\Projects\MySolution --gitbranchname=feature/update-deps
Commit but Don't Push
projects-nuget-updater C:\Projects\MySolution --gitpush=false
Default (stable-only updates)
projects-nuget-updater C:\Projects\MySolution
Allow pre-release updates
projects-nuget-updater C:\Projects\MySolution --includeprerelease=true
Combined Example: Update with Multiple Filters
Update only core projects, exclude tests, and skip updating specific packages
projects-nuget-updater C:\Projects\MySolution --filteronprojectfiles="MyApp.Core.*.csproj" --excludeprojectfiles="MyApp.Core.Tests.csproj" --excludepackagesforupdate="Microsoft.Extensions.Logging;Serilog"
Setup PAT Interactively
projects-nuget-updater setup-pat
Setup PAT with Command-Line Parameters
projects-nuget-updater setup-pat --source="Internal Azure DevOps" --token=abc123def456xyz789
Project Filtering Details
Wildcard Patterns
Use standard wildcard patterns to match multiple projects:
*.csproj- All projectsMyApp.*.csproj- All projects starting with "MyApp."*.Tests.csproj- All test projects
Matching is case-insensitive and searches recursively through all subdirectories.
Semicolon-Separated Lists
Provide exact project file names separated by semicolons:
Project1.csproj;Project2.csproj- Case-insensitive matching
- Searches recursively through all subdirectories
Exclusion Filter
The exclusion filter is applied after the main filter:
- Projects are first filtered by
--filteronprojectfiles(or all projects if not specified) - Then projects in
--excludeprojectfilesare removed from the result
Package Filtering Details
Excluding Packages from Update
The --excludepackagesforupdate option allows you to prevent specific NuGet packages from being updated, even if newer versions are available. This is useful for:
- Maintaining compatibility - Keep packages at a specific version when newer versions introduce breaking changes
- Staged updates - Update most packages while keeping critical dependencies stable
- Version pinning - Prevent automatic updates of packages that require careful migration planning
Package Exclusion Format
Provide package names separated by semicolons:
Newtonsoft.Json- Exclude a single packageNewtonsoft.Json;System.Text.Json- Exclude multiple packages- Package names are case-insensitive
- Partial name matching is not supported - use exact package names
Example Scenarios
Exclude JSON serialization libraries from update:
projects-nuget-updater C:\Projects\MySolution --excludepackagesforupdate="Newtonsoft.Json;System.Text.Json"
Update all packages except logging frameworks:
projects-nuget-updater C:\Projects\MySolution --excludepackagesforupdate="Microsoft.Extensions.Logging;Serilog;NLog"
Combine with project filtering to have fine-grained control:
projects-nuget-updater C:\Projects\MySolution --filteronprojectfiles="MyApp.Core.*.csproj" --excludepackagesforupdate="EntityFramework"
Workflow
The tool follows this workflow when updating packages:
- Validation - Validates solution directory and git repository (if enabled)
- Git Pull - Pulls latest changes from main branch (if git enabled)
- Create Branch - Creates and checks out a new branch (if git enabled)
- Pre-Build - Runs build to ensure solution is valid (if enabled)
- Pre-Test - Runs tests to ensure solution is working (if enabled)
- Update Packages - Scans and updates all NuGet packages to latest versions (stable only by default; pre-releases included when --includeprerelease=true)
- Post-Build - Runs build to validate updates (if enabled)
- Post-Test - Runs tests to validate updates (if enabled)
- Git Commit - Commits changes with descriptive message (if git enabled)
- Git Push - Pushes changes to remote repository (if git enabled)
Requirements
- .NET 10.0 Runtime or later
- Git (if using git operations)
- Solution must be in a git repository (if
--usegit=true)
PAT Configuration
Personal Access Tokens (PATs) are stored securely using Windows Data Protection API (DPAPI) on Windows and encrypted storage on other platforms.
Configuration Location:
%USERPROFILE%.nuget\pat-config.json
The PAT configuration is automatically used when authenticating to private NuGet feeds during package updates.
Troubleshooting
Git Repository Not Found
If git operations are enabled (--usegit=true), the directory must be a git repository. Either initialize git in the directory or disable git operations with --usegit=false.
Build or Test Failures
If pre-build or pre-test fails, the tool stops to prevent applying updates to a broken solution. Fix the build/test issues before running the updater.
If post-build or post-test fails after updates, you may need to manually review and fix compatibility issues with the updated packages.
PAT Authentication Failures
If authentication fails with private feeds:
- Verify your PAT is still valid
- Ensure the PAT has package read permissions
- Reconfigure the PAT using
projects-nuget-updater setup-pat
Preleases
If unexpected preview/rc versions appear, ensure --includeprerelease is not set to true.?
Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
This package has no dependencies.
- Initial Release
- Minor Fixes
- Add Option To Include or excludde Preleases
- Add Option To exclude specific Packages
- Update to .Net 10
- Update Documenation
- Update to .Net 11