Visual Studio web csproj file indenting flipping between tabs and spaces

Viewed 1005

The indentation of our web .csproj file is being changed to spaces or tabs, depending on the particular installation/user/machine doing the work. For two of us, VS 2019 will force it to indent of 2 spaces (which we want). For the other two developers, their VS will change it to tab indent whenever adding a new file to the project.

Our tab settings are the same for:

  • C# = Smart / Tab Size 4 / Insert spaces
  • XML = Smart / Tab size 4 / Keep tabs

We could not find a setting for .csproj files. The behaviour of VS does not seem to match any of the settings we checked. Is there another item in Tools / Options / Text Editor or elsewhere that governs this?

The reason this matters is, whenever we merge a changed csproj back into the common branch, if there is a difference in indenting, git doubles the size of the file, including both versions. Git doesn't recognise the lines are really the same apart from leading whitespace.

1 Answers

"Tabs to spaces" is a personal preference. NOT stored in the csproj file(which is committed to get project), but (a) defaulting from your VS preferences; or (b, most likely) overridden in project specific 'Project Preferences' file (the extension eludes me).

Private preferences shouldn't but committed to the git project, and are typically ignored in the git.ignore file. But, if that for has been stored with your project, it will now be be downloaded as 'read-only' in any pull, overriding any personal changed you've made.

The " .suo" file rings a bell. Add to git.ignore, and delete from the stored GIT project.

Related