dotnet new creates files with CRLF line endings on linux
See original GitHub issueFrom @kromatic on September 21, 2017 20:58
Steps to reproduce
Run dotnet new classlib
in new project folder.
Expected behavior
On Linux, this should create Class1.cs and .csproj files with LF line endings.
Actual behavior
Class1.cs and the .csproj file are both created with CRLF line endings. (Files in bin and obj folders appear to all have the correct LF line endings.)
Environment data
dotnet --info
output:
.NET Command Line Tools (2.0.0)
Product Information: Version: 2.0.0 Commit SHA-1 hash: cdcd1928c9
Runtime Environment: OS Name: fedora OS Version: 26 OS Platform: Linux RID: fedora.26-x64 Base Path: /usr/share/dotnet/sdk/2.0.0/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0 Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
Copied from original issue: dotnet/cli#7695
Issue Analytics
- State:
- Created 6 years ago
- Reactions:28
- Comments:30 (11 by maintainers)
Top Results From Across the Web
Is it possible to force .Net Core on Linux to use CRLF?
On Windows the final message will have CRLF but on Linux it will have LF (this new lines are put by the framework...
Read more >How to set Line Ending (CRLF, CR or LF) for all files in ...
For example , I set line ending as 'LF' … now whenever I create a new code file in VS, it should automatically...
Read more >Introducing extended line endings support in Notepad
New files created within Notepad will use Windows line ending (CRLF) by default, but it will now be possible to view, edit, and...
Read more >CRLF vs. LF: Normalizing Line Endings in Git
Line endings can differ from one OS to another. Learn the history behind CRLF and LF line endings and how to enforce line...
Read more >Best mmj doctors in denver
Info on how to create templates that work in dotnet new and Visual ... click the files and folders in Solution Explorer.csproj files...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I just ran
dotnet new [...]
for the first time on Linux, and I was rather shocked to see CRLF line endings as I staged the files in the Git repository.I would personally want native/expected behavior from a cross-platform tool, regardless of what elementary things certain editors have problems with. For example, if an editor (let’s say Notepad on Windows) can’t deal with LF, then I would rather fix the editor or use a different one.
At least for now, it seems like
git config --global core.autocrlf input
will work okay for me personally on Linux and macOS, andgit config --global core.autocrlf true
on Windows.This is currently “by design” (see https://github.com/dotnet/templating/issues/350#issuecomment-281851892). Originally, we had standardized all content on LF line endings, but this caused issues with certain editors on Windows and produced a ton of messages when adding the files to Git.
Since the content is not produced line by line, we don’t explicitly set what the line endings should be, we just emit what was included in the original content. We are looking in to a feature in the future (if there’s enough interest) where templates could indicate that files matched by certain patterns would have their line endings replaced with ones matching the platform.