CentralisedPackageConverter

repository·master·Indexed 20 days ago

https://github.com/webreaper/centralisedpackageconverter

A .NET global tool that automates the migration of C# and F# projects to Centralised Package Management (CPM) by moving package version definitions from individual project files into a single Directory.Packages.props file. It supports scanning project trees, reverting conversions, dry runs, and transitive pinning.

Tokens
778
Snippets
3
Records
5
Agent score
22%

What's inside CentralisedPackageConverter

  1. Limitations and manual steps for Centralised Package Management

    master

    When using Centralised Package Management (CPM) via this tool, be aware of the following:

    • No Floating Versions: CPM does not support floating versions, such as wildcards or range operators.
    • Implicit Digits: Omitted digits are implicitly added (e.g., "8" == "8.0" == "8.0.0").
    • Manual Edits Required: You may need to manually edit Directory.Packages.props if:
      • Versions found in projects are missing, invalid (e.g. floating), or ignored (e.g. prerelease).
      • Conditions on ItemGroup depend on the project file.
  2. Convert a project to Centralised Package Management

    master

    To convert a project to Centralised Package Management (CPM), run the tool and pass the root folder of your project as the only parameter.

    How it works:

    1. The tool scans the folder tree for all .NET project files (supports both C# and F#).
    2. It gathers all versioned package references.
    3. It removes the versions from the individual project files.
    4. It writes those version entries into a Directory.Packages.props file at the root.
    central-pkg-converter /path/to/your/project
  3. Reference: CentralisedPackageConverter CLI options

    master

    The following command-line options are available for central-pkg-converter:

    OptionFlagDescription
    Root Directory(Positional)Required. Root folder to scan for project files.
    Revert-r, --revertRevert from Centralised Package Management to project-file-based versions.
    Dry Run-d, --dry-runRead-only mode (make no changes on disk).
    Force-fForce changes (don't prompt/check for permission before continuing).
    Merge-mMerge changes with existing directory file.
    Transitive Pinning-t, --transitive-pinningForce versions on transitive dependencies (CentralPackageTransitivePinningEnabled=true).
    Encoding-e, --encodingEncoding of written files, IANA web name (e.g. utf-8, utf-16). Default is picked by .NET implementation.
    Line Wrap-l, --linewrapLine wrap style: lf=Unix, crlf=Windows, cr=Mac. Default is system style.
    Min Version-v, --min-versionPick minimum instead of maximum package version number.
    Ignore Prerelease-p, --ignore-prereleaseIgnore prerelease versions.
    Version Comparison-c, --version-comparisonWhich NuGet version parts to consider: Default, Version, VersionRelease, VersionReleaseMetadata (enum NuGet.Versioning.VersionComparison).
    Exclude Dirs-x, --exclude-dirsExclude directories matching this regular expression (Default = ^\.|^bin$|^obj$).