autoformat code from command line

前端 未结 5 844
执念已碎
执念已碎 2020-12-14 01:59

Is it possible to run auto-format code for all or for specific file in solution, like (Ctrl+K, Ctrl+D) formatting in Visual Studio but from it`s command line? Or use Reshar

5条回答
  •  隐瞒了意图╮
    2020-12-14 02:36

    Use CodeFormatter from the .NET Team

    1. Install MSBuild Tools 2015.
    2. Download CodeFormatter 1.0.0-alpha6.
    3. Add CodeFormatter.csproj to the root directory of your projects:

    CodeFormatter.csproj

    
      
        
      
      
        
      
    
    

    Then run this from the Command Line.

    > codeformatter.exe CodeFormatter.csproj /nocopyright
    

    The result: all your projects' C# files now adhere to the majority of the .NET Foundation coding guidelines.

    Remarks

    • Installing MSBuild Tools 2015 means that we do not need Visual Studio.
    • Adding CodeFormatter.csproj to the root directory recursively includes all C# files, which means the above works with project.json and *.xproj based setups.

    See also

    http://bigfontblog.azurewebsites.net/autoformat/

提交回复
热议问题