1

To get around the issue of Git modifying the line endings of static Blazor files, most people are recommending that you create a .gitattributes file with "* binary" as its only contents to force git to treat these files as binary instead of text. In video tutorials that I have followed line by line, this works as intended.

When I do the same locally, I still get one file, dotnet.5.0.3.js, having its line endings modified, which in turn causes the sha256 integrity checks to fail.

Is there another method I can try instead? You can see the project's gh-pages branch here (https://github.com/TDuffinNTU/gh-blazor/tree/gh-pages) which is identical to the one I'm copying from a tutorial, which works just fine.

TDuff
  • 78
  • 7
  • I've also just tried adding the path to the dotnet.5.0.3.js explicitly to the .gitattributes file to no avail. – TDuff Nov 29 '21 at 23:42
  • It seems likely that something created the .js file and wrote it into Git and *then* set the `.gitattributes` file up, after it was a bit too late. If so, `git rm --cached` the file and then `git add` it again (that's the rude/crude way, `git add --renormalized` lets you skip the rm step but doesn't work in some rather old Git versions). – torek Nov 30 '21 at 05:55
  • I figured there was some kind of order of operations issue, so I did a few builds where the gitattributes file was kept on the branch while everything else was deleted, committing inbetween. I'll try your other suggestions later :) – TDuff Nov 30 '21 at 12:27
  • Okay so I think I've done it! I had to install git-scm on my work laptop to use it in the terminal, and noticed that there's an installer option that configures the auto crlf endings. I disabled it (which I know is bad practice usually but my line endings for everything else has already been altered for the build project anyway) so I think that's now working as intended!! – TDuff Nov 30 '21 at 12:53

2 Answers2

0

So git-scm by default set auto CRLF to true (core.CRLF = true I think?) which must take precedence over my gitattributes file.

Having installed git-scm on a different machine and changing the default during the installation process it's now correctly preserving line endings and my deployment is working!

You can also edit your .gitconfig file from the commandline or locate it in your C:/Users/$USER folder and modify it there.

Thanks a bunch to Torek for their kind suggestions which prompted me to install on my work machine and lead me to my solution.

TDuff
  • 78
  • 7
0

I used this command and it work for me

 git config --global core.autocrlf false

from the very long answer here Windows git "warning: LF will be replaced by CRLF", is that warning tail backward?

tomdinh
  • 178
  • 8