Git Product home page Git Product logo

mbw.tools.csprojformatter's Introduction

MBW.Tools.CsProjFormatter Generic Build NuGet GHPackages

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 <dir> 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.

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.

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.

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.

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:

<PackageReference>
  <Include>My.Package</Include>
  <Version>3.1.1</Version>
<PackageReference>

Becomes:

<PackageReference Include="My.Package" Version="3.1.1" />

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:

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
    <PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="2.0.4" />
    <PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.2.0" />
  </ItemGroup>

Becomes:

  <ItemGroup>
    <PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.3.4" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
    <PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="2.2.0" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="2.0.4" />
    <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
  </ItemGroup>

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.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <Version>0.1.0</Version>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="My.Package" Version="1.2.3.4" />
  </ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <Version>0.1.0</Version>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="My.Package" Version="1.2.3.4" />
  </ItemGroup>

</Project>

mbw.tools.csprojformatter's People

Contributors

lordmike avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.