organize-csproj 1.1.3-a

A tool for organizing csproj files. Groups and sorts ItemGroups based on item type and file extension.

This is a prerelease version of organize-csproj.
There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global organize-csproj --version 1.1.3-a
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 organize-csproj --version 1.1.3-a
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=organize-csproj&version=1.1.3-a&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
nuke :add-package organize-csproj --version 1.1.3-a
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Usage

Install from NuGet as a global dotnet tool.

Then, use it on a project file:

organize-csproj --input=your-project.csproj

Alternatively, you can use it on a solution file to organize all Projects associated with the solution. Simply run the below line in the directory where a .sln file exists.

organize-csproj --scan

CLI Arguments

Use --help to see command line arguments for the version you're using.

On a Solution File

You can use a solution file to organize all associated project files, you only need to use the --scan flag:

--scan

Individual Project files

--input

Description: The path to a .csproj file.

Default: None

Required: Yes

--output

Description: The filename to save the input.csproj after it has been sorted.

Default: The value of --input (overwrites existing file)

Required: No

--config

Description: The path to a configuration json file

Default: None

Required: No

Example

dotnet organize-csproj --input=project.csproj --output=project.sorted.csproj --config=my.config.json

Configuration

The default configuration can be seen here: csproj.config.defaults.json It should work as a solid reference to get yourself started. The configuration needs to map to SortConfiguration.cs.

If this isn't sufficient documentation, open an issue and I'll write out more.

Sort Options

Below are the primary steps taken when cleaning up a .csproj file.

They each can be disabled using your own configuration file, like so:

{
  "SortOptions": {
    "GroupByNodeType": true,
    "GroupByFileType": true,
    "RemoveEmptyItemGroups": true,
    "SortItemsWithinItemGroups": true
  }
}

They all default to true.

  • GroupByNodeType
    • Groups all Items of the same type into their own <ItemGroup>

      (e.g., <Content>, <Compile>, <TypeScriptCompile>, etc)

  • GroupByFileType
    • Creates <ItemGroup>s for each distinct filetype
    • Subdivides existing <ItemGroup>s into even more granular <ItemGroup>s
  • RemoveEmptyItemGroups
    • Removes <ItemGroup>s without any children. The tool doesn't create empty <ItemGroup>s―this option is for tidying up.
  • SortItemsWithinItemGroups
    • Whether to alphanum sort all <ItemGroup>s. Performed last.

Usage

Install from NuGet as a global dotnet tool.

Then, use it on a project file:

organize-csproj --input=your-project.csproj

Alternatively, you can use it on a solution file to organize all Projects associated with the solution. Simply run the below line in the directory where a .sln file exists.

organize-csproj --scan

CLI Arguments

Use --help to see command line arguments for the version you're using.

On a Solution File

You can use a solution file to organize all associated project files, you only need to use the --scan flag:

--scan

Individual Project files

--input

Description: The path to a .csproj file.

Default: None

Required: Yes

--output

Description: The filename to save the input.csproj after it has been sorted.

Default: The value of --input (overwrites existing file)

Required: No

--config

Description: The path to a configuration json file

Default: None

Required: No

Example

dotnet organize-csproj --input=project.csproj --output=project.sorted.csproj --config=my.config.json

Configuration

The default configuration can be seen here: csproj.config.defaults.json It should work as a solid reference to get yourself started. The configuration needs to map to SortConfiguration.cs.

If this isn't sufficient documentation, open an issue and I'll write out more.

Sort Options

Below are the primary steps taken when cleaning up a .csproj file.

They each can be disabled using your own configuration file, like so:

{
  "SortOptions": {
    "GroupByNodeType": true,
    "GroupByFileType": true,
    "RemoveEmptyItemGroups": true,
    "SortItemsWithinItemGroups": true
  }
}

They all default to true.

  • GroupByNodeType
    • Groups all Items of the same type into their own <ItemGroup>

      (e.g., <Content>, <Compile>, <TypeScriptCompile>, etc)

  • GroupByFileType
    • Creates <ItemGroup>s for each distinct filetype
    • Subdivides existing <ItemGroup>s into even more granular <ItemGroup>s
  • RemoveEmptyItemGroups
    • Removes <ItemGroup>s without any children. The tool doesn't create empty <ItemGroup>s―this option is for tidying up.
  • SortItemsWithinItemGroups
    • Whether to alphanum sort all <ItemGroup>s. Performed last.

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.1.5 297 11/1/2020
1.1.3 196 10/26/2020
1.1.3-a 186 10/26/2020
1.0.3 153 10/17/2020