The GoLang blog says it best. Having an automated, canonical, code-formatting tool as part of the build makes your code: "easier to write... easier to read... easier to maintain... [and] uncontroverial."
- Install MSBuild Tools 2015.
- Download CodeFormatter 1.0.0-alpha6.
CodeFormatter.csprojto the root directory of your projects:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup> <Compile Include="**\*.cs" /> </ItemGroup> <Target Name="Compile"> <Csc Sources="@(Compile)"/> </Target>
Then run this from the Command Line (it helps if you've added the extracted ZIP file to your PATH).
> codeformatter.exe CodeFormatter.csproj /nocopyright
The result: all your projects' C# files now adhere to the majority of the .NET Foundation coding guidelines.
- Installing MSBuild Tools 2015 means that we do not need Visual Studio.
CodeFormatter.csprojto the root directory recursively includes all C# files, which means the above works with project.json and *.xproj based setups.