question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dotnet new creates files with CRLF line endings on linux

See original GitHub issue

From @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:open
  • Created 6 years ago
  • Reactions:28
  • Comments:30 (11 by maintainers)

github_iconTop GitHub Comments

29reactions
SteffenLcommented, Sep 23, 2017

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, and git config --global core.autocrlf true on Windows.

29reactions
mlorbetskecommented, Sep 22, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found