DotNetCsprojPackageSorter 1.0.10

dotnet tool install --global DotNetCsprojPackageSorter --version 1.0.10
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local DotNetCsprojPackageSorter --version 1.0.10
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=DotNetCsprojPackageSorter&version=1.0.10
                    
nuke :add-package DotNetCsprojPackageSorter --version 1.0.10
                    

DotNetCsprojPackageSorter

A .NET global tool to keep your .csproj files clean and organized. It automatically sorts PackageReference entries alphabetically and normalizes spacing between ItemGroup and PropertyGroup elements.

Features

  • Sort Dependencies: Alphabetizes PackageReference items within ItemGroup.
  • Formatting: Ensures proper spacing (e.g., inserts a newline between </PropertyGroup> and <ItemGroup> if missing).
  • Safe Mode: Optionally create a backup (.bak) of the file before modifying.
  • Dry Run: Preview changes without modifying the file.
  • CI Integration: Use --check to verify sorting in CI/CD pipelines (returns exit code 1 if unsorted).

Installation

Install the tool globally using the .NET CLI:

dotnet tool install -g DotNetCsprojPackageSorter

Usage

Run the tool on a specific .csproj file:

dotnet-csproj-sort <path-to-csproj> [options]

Options

Option Description
-h, --help Show help information.
--version Show version information.
--backup Create a .bak file before modifying the project file.
--dry-run Show what changes would be made without actually modifying the file.
--check CI mode. Checks if the file is sorted and returns exit code 1 if it is not. Useful for build pipelines.

Examples

Sort a project file in place:

dotnet-csproj-sort MyProject.csproj

Sort with a backup:

dotnet-csproj-sort MyProject.csproj --backup

Check if a file is sorted (returns error code if not):

dotnet-csproj-sort MyProject.csproj --check
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.0.10 101 2/18/2026