dotnet-sort-refs 2.3.0

dotnet tool install --global dotnet-sort-refs --version 2.3.0
                    
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 dotnet-sort-refs --version 2.3.0
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=dotnet-sort-refs&version=2.3.0
                    
nuke :add-package dotnet-sort-refs --version 2.3.0
                    

<img src="https://raw.githubusercontent.com/mysticmind/dotnet-sort-refs/master/assets/icon.png" alt="dotnet-sort-refs icon: a list of package references with an A to Z arrow" width="96">

dotnet-sort-refs

CI NuGet Version

A .NET global tool to alphabetically sort package references in your .csproj, .fsproj and .props files, including Directory.Packages.props for central package management.

If you have benefitted from this library and has saved you a bunch of time, please feel free to buy me a coffee!<br> <a href="https://github.com/sponsors/mysticmind" target="_blank"><img height="30" style="border:0px;height:36px;" src="https://img.shields.io/static/v1?label=GitHub Sponsor&message=%E2%9D%A4&logo=GitHub" border="0" alt="GitHub Sponsor" /></a>

Why use this tool?

References and package references in a project file are the most updated parts. Sorting the references helps with the following:

  • Easier merges on source control (git). Without sorting the package references in the project file, you may end up with more merge conflicts to fix.
  • It will be easier to go through the list of package references if you manually edit the file or view changes using a diff tool.

Installation

dotnet tool install --global dotnet-sort-refs

Version 2.3.0 and later requires .NET 8 or newer. It also runs on any newer runtime you have installed, including future major versions.

If you only have an older runtime (.NET Core 3.1 or .NET 5, 6 or 7), install version 2.2.0, the last release that supports them:

dotnet tool install --global dotnet-sort-refs --version 2.2.0

Usage

Usage: dotnet sort-refs [options] <Path>

Arguments:
  Path          The path to a .csproj, .fsproj or .props file, or a directory.
                If a directory is specified, all .csproj, .fsproj and .props
                files within the folder tree will be processed, skipping bin and
                obj folders. If none is specified, the current directory is
                used.

Options:
  --version     Show version information.
  -?|-h|--help  Show help information.
  -i|--inspect  Specifies whether to inspect and return a non-zero exit code if
                one or more projects have non-sorted package references.

Note: dotnet sort-refs and dotnet-sort-refs are valid usages to run the tool.

Development

Build and run the tests from the repository root:

dotnet build src/DotNetSortRefs.sln
dotnet test --project src/DotNetSortRefs.Tests/DotNetSortRefs.Tests.csproj

Building every target needs the .NET 11 SDK. The tests target .NET 10 and run against an in-memory file system, so they never touch real project files.

Product 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 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.  net11.0 is compatible. 
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
2.3.0 70 11/28/2026
2.2.0 123,705 3/16/2026
2.1.0 20,316 5/14/2025
2.0.0 41,160 1/29/2024
1.0.1 14,613 11/12/2021
0.2.1 2,556 1/14/2020
0.2.0 1,032 1/13/2020 0.2.0 is deprecated because it has critical bugs.
0.1.0 935 3/22/2019