-
Notifications
You must be signed in to change notification settings - Fork 372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet new creates files with CRLF line endings on linux #1248
Comments
This is currently "by design" (see #350 (comment)). 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. |
I just ran 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 |
This is incredibly frustrating on non-Windows platforms. If you forget about this bug before you start making changes to your code, you can easily end up with mixed line endings, which confuses all sorts of tooling. Fixing it for the whole repo requires |
Could we get an update on the current status of this bug? The last comment in the referenced issue says:
but dotnet new still produces CRLF? |
I also encountered this problem today, and I disapprove the decision of keeping this behaviour by design. If there are some editors on Windows which have troubles handling LF endings, then it should be their responsibility to fix their behaviour, not yours. |
Carriage Returns were designed for mechanical typewriters. What year is it again? Is there seriously no option to tell the dotnet cli to not add carriage returns? There's no config file or environment variable? What bubble do you live in to think that this is Ok? I think the emperor needs to put on some clothes - I'm here to tell you that the world does not use CRLF anymore and if you depend on it then you're being left behind. |
This behavior of dotnet cli is very frustrating for me. I'm waiting maybe some flag for line ending, or something else like this. |
Looks like this issue is resolved. I have just checked on Linux, all files contain LF endings. |
@grinrag, hi! It still repduces for me. It is very frustrating because OmniSharp in VSCode seems to work only when the files have LF as line endings. Otherwise, there is no highlighting or hints. .NET Core SDK (reflecting any global.json): Runtime Environment: Host (useful for support): .NET Core SDKs installed: .NET Core runtimes installed: |
I can replicate the issue on MacOS Catalina too. .net version installed: 3.1.403 |
Still reproducible on .NET 5.0
|
Still reproducible in .NET 6 Preview 3. Worse yet, it even uses
|
@keegandent notice .sln file format is Visual Studio file format which was in past Windows only and as far as I know doesn't work with parsing When it comes to line endings its up to template author to decide which line ending which file will be, we should probably reconsider default for Engine itself could provide is ability for template author to specify for which files in template line ending can change and then engine changes line endings based on operating system + add flag for user to override that for example But notice that we can't just enable this for all files, because for example some file formats/extension must stay in |
@DavidKarlas For the record the Changing the |
Wouldn't it make more sense to fix the tools instead of keeping legacy baggage around? |
Wouldn’t that create issues for Windows users in that case? (i.e. changing default to LF)
Sounds sensible
Why should they stay in that format? |
Notice that bug is open and we plan to fix this, question is just how |
Well the "poor man's" fix would be to generate the solution or project template as normal, but run the human-readable files through a |
I don't think that solution would be too bad if you also run it through dotnet-format to get a consistent coding style (though dotnet-format still has some gaps). |
Just wanted to mention we didn't forget about this issue and I found nice example why we can't just blindly convert Lets assume that template has 2 files:
Lets say that user creates this template on Windows, what will end up happening is that |
Is it really necessary to keep I know that most (all?) tools on Windows will work with |
discussed with @baronfel, there are 2 approaches to implement this feature:
1st approach is preferred, but need to be planned accordingly as it's a big chunk of work. |
Are we any closer here? I have to say this is very frustrating on macOS and requires the creation and use of a script that detects and converts files via |
Yes this is something that really does need sorting. Creating a blazer or Maui app on Mac creates a lot of files that you have to cover before committing to git. Really frustrating. |
Additionally, I'd wish to see the templating produces files without BOM. |
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
The text was updated successfully, but these errors were encountered: