Templating: crlf vs lf in templates

Created on 21 Feb 2017  ·  13Comments  ·  Source: dotnet/templating

I used to be able to do dotnet new and it would create project that could be read in notepad. Since the new engine was changed this is no longer the case. There are plenty of debates that could be had about how to do this right. The new behavior may be the right default, maybe not? Maybe there should be an option?

All 13 comments

@sayedihashimi @blackdwarf thoughts?

I just noticed the same thing and it bugged me. Seems like we should at least honor the native Environment.NewLine value. Bonus points if you read .gitattributes and honor it.

Since I was asked, I don't see a huge problem with it, seeing as how most developers will have editors that can show LFs as they were intended. But, @ericstj has a point from a design perspective. I'm fine either way, but I'm not sure that this meets the bar for v1?

I think we should change to CRLF and then see if we get any user feedback. But I don't think this meets any bar for any release that's locking down.

Perhaps you should let shiproom make that decision? It seems to me that this could look pretty bad for someone trying out our stuff for the first time and using the "wrong" editor.

@mlorbetske can you clarify what's the shiproom bar?

The bar is largely crashes, hangs, security issues, high hit rate issues and the like. Cosmetic issues, limited impact issues, things with easy workarounds, easily diagnosable issues, etc generally don't meet the bar at this point.

Thanks @mlorbetske, this clearly doesn't meet the bar.

Just got this from another developer:

  • Line ending for projects. Now all the files that dotnet new creates use “LF” line-endings so I get a bunch of warnings from git like:
    > git add .
    warning: LF will be replaced by CRLF in samples/NuGet.config.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in samples/Program.cs.
    The file will have its original line endings in your working directory.
    warning: LF will be replaced by CRLF in samples/samples.csproj.
    The file will have its original line endings in your working directory.

I hit this as well. The experience is bad and as @Petermarcu points out you get noise from git when you add stuff later on depending on your autocrlf setting. I get it not meeting the bar for 1.0 but are we going to fix it for 2.0?

Yes we are planning to fix for the next release.

This is now fixed

I'm trying to use a custom template on Windows but getting LF in _all_ files, except the few specified other than text=auto in .gitattributes, so this doesn't seem to be fixed. 😕

Not sure it's relevant but we build the NuGet package for the custom dotnet template with dotnet sdk 3.1.201 in a Docker container on Linux.

Was this page helpful?
0 / 5 - 0 ratings