https://github.com/lordmike/mbw.tools.csprojformatter
Dotnet global tool to format CSProj files, sorting dependencies and indenting elements
https://github.com/lordmike/mbw.tools.csprojformatter
csproj formatter
Last synced: 20 days ago
JSON representation
Dotnet global tool to format CSProj files, sorting dependencies and indenting elements
- Host: GitHub
- URL: https://github.com/lordmike/mbw.tools.csprojformatter
- Owner: LordMike
- License: mit
- Created: 2019-09-15T17:41:22.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-09-19T21:15:02.000Z (over 1 year ago)
- Last Synced: 2025-04-01T17:10:36.667Z (28 days ago)
- Topics: csproj, formatter
- Language: C#
- Homepage:
- Size: 42 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# MBW.Tools.CsProjFormatter [](https://github.com/LordMike/MBW.Tools.CsProjFormatter/actions/workflows/dotnet.yml) [](https://www.nuget.org/packages/MBW.Tools.CsProjFormatter) [](https://github.com/LordMike/MBW.Tools.CsProjFormatter/packages/703133)
Dotnet tool to format `.csproj` files.
## Installation
Run `dotnet tool install -g MBW.Tools.CsProjFormatter`. After this, `csproj-format` should be in your PATH.
## Usage
Run `csproj-format ` to recursively format all `.csproj` and `.targets` files in that directory. Multiple directories can be specified. The help page (`--help`) details more options that can be set, f.ex. dry-run (`-n`) or including/excluding more file types (`--include` and `--exclude`).
## Configuration
The formatter reads all appropriate `.editorconfig` files as specified by that standard (reading all parent editor configs etc.). Configure the options for `.csproj` and `.targets` as appropriate.
### Options
#### indent_style and indent_size
The formatter respects the `indent_style` and `indent_size` options. If specified, indentation of all formatted files will be as specified.
These are part of the ["default" options](https://editorconfig-specification.readthedocs.io/en/latest/#supported-properties).
#### end_of_line
The formatter respects the `end_of_line` option. If specified, all line endings will be converted to match the specified value. Supported values: `cr`, `lf`, `crlf`
This is part of the ["default" options](https://editorconfig-specification.readthedocs.io/en/latest/#supported-properties).
#### charset
The formatter respects the `charset` option. If specified, all files will be rewritten in the specified encoding. Supported values: `latin1`, `utf-16be`, `utf-16le`, `utf-8`, `utf-8-bom`.
This is part of the ["default" options](https://editorconfig-specification.readthedocs.io/en/latest/#supported-properties).
#### insert_final_newline
The formatter respects the `insert_final_newline` option. If specified, all files will include a trailing empty line.
This is part of the ["default" options](https://editorconfig-specification.readthedocs.io/en/latest/#supported-properties).
#### csproj_prefer_package_reference_attributes
If `csproj_prefer_package_reference_attributes` is specified to `true`, the formatter will convert all "verbose" package references to more compact ones.
Example:
```xmlMy.Package
3.1.1```
Becomes:
```xml
```
#### csproj_sort_package_project_references
If `csproj_sort_package_project_references` is specified to `true`, the formatter will sort all ItemGroups that include ONLY `PackageReference` and `ProjectReference` statements.
Example:
```xml
```Becomes:
```xml
```#### csproj_split_top_level_elements
If `csproj_split_top_level_elements` is specified to `true`, the formatter will split all top-level declarations by one empty line.
```xml
netcoreapp2.2
0.1.0
```
```xml
netcoreapp2.2
0.1.0
```