format icon indicating copy to clipboard operation
format copied to clipboard

Support formatting .csproj .sln

Open snebjorn opened this issue 5 years ago • 4 comments

Hi I just noticed that the .csproj file isn't formatted when running dotnet-format. I'm assuming it's the same for .sln.

Think it would be a good to also format these files.

snebjorn avatar Apr 16 '20 15:04 snebjorn

It would be nice to also format Solution Files (for example, docker-compose.yaml). At least whitespace/tabs + newlines.

nothrow avatar Jul 08 '20 14:07 nothrow

I took a stab at making a csproj formatter once, I found some neat ways I could trick the msbuild project system to load my csproj files while preserving formatting.

My code supports a few scenarios:

  • Newlines between elements
  • Sort package and project references
  • Simplify some elements (package references with child elements instead of attributes)

It could work as a starting point for what's possible. It'd be great to have this and more in dotnet-format instead of my code.. :)

LordMike avatar Jan 20 '22 23:01 LordMike

@JoeRobich Any updates on this one?

Just checking the basic editorconfig rules like indentation, eol, etc. should be fine in this case. A large part of the code for that should already be present in dotnet-format anyways.

The team quite often manage to commit tabs in our *.csproj files and our dotnet-format based linter is not able to catch this.

flobernd avatar Nov 01 '22 23:11 flobernd