Please apply EditorConfig settings to template files
When creating projects and solutions using dotnet new, it doesn't respect an existing EditorConfig file, and you end up with 2-space indentation, CRLFs, and some files (like launchSettings.json) with a BOM.
This isn't very cross-platform-friendly. In fact, the project was added from Linux, and I still got CRLFs.
Please:
- Read and apply settings from an existing EditorConfig file.
- If there is no EditorConfig file, apply settings based on the OS (f.e. LF on Linux and macOS).
This should not require any parsing or understanding of the template itself. Most text-like files can have these settings applied, or you can maintain a simple list of files (file extensions) that support them.
The following EditorConfig settings should be applied:
charset end_of_line indent_size indent_style insert_final_newline trim_trailing_whitespace
This would make it easier to get started without having to spend time fixing the files.
Related: https://github.com/dotnet/templating/issues/1248
Ideally dotnet format would be called as an implicit post action and would apply the formatting changes. Unfortunately dotnet format is quite slow due to need to perform project evaluation.
Per discussion with @baronfel, we should try to inspect option of using dotnet format whitespace, skips the evaluation.
@JanKrivanek
The problem with that is that dotnet format doesn't support files like .csproj .sln, .cshtml .razor, or other template files like appsettings.json, etc.
I wonder if dotnet format should add support for basic EditorConfig formatting in all (most) file types.
I've opened https://github.com/dotnet/format/issues/1798.
Close as duplicate of https://github.com/dotnet/templating/issues/5505. Please follow up there.