I have been taking for granted about line ending till I stumble upon a manifest mismatch on VSTO project. I used to think that storing in Unix-style in the remote Git repo, but working on Windows-style is the way to go. That way, I was allowing collaborators to choose their own style. But hey, VSTO only lives in Windows. Who cares about this generic rule of thumb!
I cloned a installer project for VSTO from a Git repo. All went well, but I got this error when trying to test the VSTO project on my Microsoft Word.
System.Deployment.Application.InvalidDeploymentException: Application manidest has either a different computed hash than the one specified or no has specified at all.
The above error tells that the manifest file does not match because of different computed hash. In a plain English, the manifest file might have been changed. And, the Git handling on line ending is the culprit.
git config core.autocrlf
The rule of thumb is to set it to ‘true’ for Windows and ‘input’ for Mac or Linux. Below is the
- ‘true’ => Checkout Windows-style, commit Unix-style
- ‘input’ => Checkout as-is, commit Unix-style
- ‘false’ => Checkout as-is, commit as-is
Having set the value to true would make the manifest file being modified while committing this file. Hence, we can specify this autocrlf in this particular project to false. Don’t try to change the value globally to false.
However, this solution is not quite elegant. Fortunately, Git offers more flexibility on dealing with this issue: adding .gitattributes file.
This -text means that the files will not get normalized.