How can I integrate Fantomas with MSBuild / dotnet CLI

119 Views Asked by At

I have F# solutions and projects that build using the .NET Core CLI (dotnet build). I would like to format my code using Fantomas (dotnet tool run fantomas).

The problem is that Fantomas does not understand .sln or .fsproj files. This means that I will need to maintain a script for calling Fantomas on each of my project files, which might become out-of-sync over time.

Is there a mechanism for easily using Fantomas with MSBuild that I am not aware of?

1

There are 1 best solutions below

0
knocte On

What's wrong with applying fantomas to all .fs files in a certain directory? This way you don't need to involve .sln or .fsproj files.

In case there's a specific file that you don't want to pass by the formatter, you can include it in a .fantomasignore file.

Related Questions in F#