dotnet-sort-refs
2.3.0
dotnet tool install --global dotnet-sort-refs --version 2.3.0
dotnet new tool-manifest
dotnet tool install --local dotnet-sort-refs --version 2.3.0
#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
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 | 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 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. |
This package has no dependencies.