CPMGen 0.1.7
dotnet tool install --global CPMGen --version 0.1.7
dotnet new tool-manifest
dotnet tool install --local CPMGen --version 0.1.7
#tool dotnet:?package=CPMGen&version=0.1.7
nuke :add-package CPMGen --version 0.1.7
CPMGen
A command-line tool that helps you quickly migrate large .NET solutions to Central Package Management (CPM). CPMGen automatically generates Directory.Packages.props files and updates your .csproj files, making the transition to centralized package management effortless.
Why CPMGen?
Migrating large solutions with multiple projects to Central Package Management can be tedious and error-prone. CPMGen automates this process, allowing you to modernize your .NET solution's package management in seconds instead of hours.
Features
- π Automatically scans for
.slnor.csprojfiles in your solution, or you can tell it where to look - π¦ Generates
Directory.Packages.propswith all package versions centralized - π Updates project files to remove version attributes automatically
- πΎ Built-in backup functionality to keep your original files safe
- π« Optional
.gitignoreintegration for backup directories
Installation
# Install as a global .NET tool
dotnet tool install --global CPMGen
After installation, the CPMGen command will be available globally in your terminal.
Usage
Basic Usage
# Convert all projects in current directory
CPMGen
# Convert projects in a specific solution
CPMGen -s path/to/solution
# Convert a specific project
CPMGen -p path/to/project.csproj
Options
| Option | Short | Description | Default |
|---|---|---|---|
--solution |
-s |
Directory to search for .sln files (overrides project option) |
. (current directory) |
--project |
-p |
Directory or path to .csproj file(s) |
- |
--output-dir |
-o |
Output directory for Directory.Packages.props |
. (current directory) |
--keep-attrs |
-k |
Keep Version attributes in .csproj files |
false |
--no-backup |
-n |
Disable automatic backup of .csproj files |
false |
--backup-dir |
- | Directory for backing up modified .csproj files |
. (current directory) |
--add-gitignore |
- | Add backup directory to .gitignore (creates if missing) |
false |
--gitignore-dir |
- | Directory for .gitignore |
. (current directory) |
Examples
# Default behavior - convert all projects in current directory
CPMGen
# Convert only a specific project
CPMGen -p path/to/project.csproj
# Specify custom output directory
CPMGen -o ../upDir
# Convert solution with custom backup location
CPMGen -s ./src --backup-dir ./backups --add-gitignore
# Convert without creating backups
CPMGen -n
# Keep version attributes in project files
CPMGen -k
What is Central Package Management?
Central Package Management (CPM) is a NuGet feature that allows you to manage all your package versions in a single Directory.Packages.props file rather than scattered across individual project files. This provides:
- Consistency: Ensures all projects use the same package versions
- Maintainability: Update a package version in one place, apply everywhere
- Reduced conflicts: Fewer merge conflicts in project files during team collaboration
- Better overview: See all your dependencies and versions at a glance
Learn More About CPM
How it works
On a standard execution:
- You run
cpmgen - Scans the current directory for
.slnfiles, if multiple are found you can choose one - Parses all the projects defined in the
.slnfile - Backs up all the
.csprojfiles it'll have to udpate so you won't lose any data - Generates the
Directory.Packages.propsfile with all the packages + versions found in all the projects - Updates the
.csprojfiles to removeVersionattributes from package references
Requirements
- .NET SDK: Currently the tool is configured to be built for
.NETversions 8 & 9, but I'll add other versions support soon - Project Format: SDK-style
.csprojfiles (the modern XML format) - Operating System: Windows, macOS, or Linux
Compatibility Note
CPMGen works with SDK-style projects introduced in 2017. It does not support the legacy .csproj format used in older .NET Framework projects. If you have a mixed solution, only SDK-style projects will be processed.
Contributing
Contributions are welcome! Whether it's bug reports, feature requests, or code contributions, your input helps make CPMGen better for everyone.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License. It provides maximum flexibility, allowing you to use, modify, distribute, and sublicense the software with minimal restrictions. See the LICENSE file for details.
Support
If you encounter any issues or have questions:
- π Report a bug
- π‘ Request a feature
- π¬ Ask a question
Acknowledgments
Built to simplify the adoption of NuGet's Central Package Management feature in the .NET ecosystem.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
This package has no dependencies.