Open sommmen opened 3 years ago
Hi @sommmen, Unfortunately, we do not currently support formatting .csproj files. We have an open feature request (https://github.com/dotnet/format/issues/647) to add this support. What type of formatting options are you expecting (tabs vs. spaces, charset, consistent indentation, ...)?
@JoeRobich Hiya - thanks for answering my question.
The issue i'm having right now is that i used PowerShell to bulk edit .csproj files to make sure the RootNameSpaceName and AssemblyName elements were consistently prefixed with a shortname of the company, eg:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>CMP.AuthApi</RootNamespace><AssemblyName>CMP.AuthApi</AssemblyName></PropertyGroup>
</Project>
As you can see from the resulting xml - that doesn't look too good. Also it means that i get a lot of changed files. I gave up on getting the output to format correctly in PowerShell so i moved to look for some kind of tool.
In a more broader sense, for me, i'd like the format tool to format the .csproj the same way visual studio does to remain consistent. I gues in my mind the identation is the most important.
EDIT: This SO describes my issue somewhat https://stackoverflow.com/q/58245356/4122889
Please include XML, XSD files to this request
We have this configuration in .editorconfig but its not auto formatted [*.{xml,xsd}] max_line_length = off end_of_line = lf indent_style = space charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true indent_size = 2
@JoeRobich It is silly but the IDE of a coworker of mine inserts package references like so:
<PackageReference Include="MassTransit" Version="8.0.7" />
and my IDE (vs) does it like so:
<PackageReference Include="MassTransit" Version="8.0.7"/>
If you notice there is a whitespace after the last attribute, it always causes conflict when merging.
Rider has the option to control this whitespace and can be added to .editorconfig https://www.jetbrains.com/help/resharper/EditorConfig_XML_XmlCodeStylePageSchema.html#resharper_xml_space_after_last_pi_attribute but only rider respects it, vs & vs code doesn't. So it would be great if dotnet format
could enforce that.
I would also love to upvote that dotnet format could format additional extensions according to the editor config, or the built in tools options formatting. If editor -> advanced -> format document can do it, it would be awesome for dotnet format to support it as well.
Optionally, you could take a list of extensions on the command line arguments that would let developers control which extensions were formatted?
Hiya,
I'm looking for something that can format all .csproj files - is that something that this tool can do, and if so - what would the command look like?