Can I run EditorConfig over C# Files From the Command Line?
Asked Answered
G

1

8

Newer versions of Visual Studio Support EditorConfig within the IDE which is useful, however it would be best if I could run it from the command line (and therefore in automation).

Is there any stand alone tool that supports all of the EditorConfig Settings as the Visual Studio IDE does? Microsoft Docs: .NET coding convention settings for EditorConfig

Here's what I have found so far:

Baring a stand alone tool is there any way to force Visual Studio into running the code cleanup "headless"? That might be my only solution.

Grabowski answered 13/11, 2018 at 15:36 Comment(0)
R
8

I've been hunting for the same thing, just found a very new tool for this, dotnet-format, put out from the Roslyn team:

https://github.com/dotnet/roslyn/tree/master/src/Tools/dotnet-format

From their README:

dotnet-format is a code formatter for dotnet that applies style preferences to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used.

Looks like the indented usage is something like:

$ dotnet format -w MyApplication.sln
Reminiscent answered 14/2, 2019 at 2:1 Comment(2)
for .Net Core 5 1: dotnet tool install -g dotnet-format, then 2: dotnet-format -wWeisshorn
dotnet format --verify-no-changes --include SomeFiles.cs takes around 4 seconds for a single file. Thanks you, Microsucks.Taker

© 2022 - 2024 — McMap. All rights reserved.