12

Visual Studio autogenerates this file. Searching for info on it tells me to never edit this file. Fine, but do I need to store it in my VCS or can VS auto-regenerate it whenever needed?

Wilbert
  • 7,251
  • 6
  • 51
  • 91

3 Answers3

11

I believe that Settings.Designer.cs and other similar files should be under version control.

I ran into problems using the advice of the other answer here on this question.

Settings.Designer.cs is only modified if changes are made to Settings.settings, and it is auto generated by Visual studio, but not by build tools.

When I removed Settings.Designer.cs I ran into issues where Visual Studio wasn't auto-generating the file when expected, and I had to do several rebuilds/reloads of my project until finally it randomly appeared, and I'm not sure what actually triggered it.

Also I was having issues on our TeamCity build server because the build tools there were not generating the file, so I had build failures saying it was unable to find Settings.Designer.cs

I found a good rule of thumb in this answer on another question, that basically if the build system modifies the file, then don't put it in source control, but if it is only modified when you make changes to another file and is generated by visual studio, then it probably should be in version control.

Also, Visual Studio 2017 can automatically create a Git repo with a .gitignore file when creating a new project, and by default all of the *.Designer.cs files are included in the Git repo.

TJ Rockefeller
  • 3,178
  • 17
  • 43
  • 4
    I think it's telling that "by default all of the *.Designer.cs files are included in the Git repo." This should be the accepted answer. – jsmith Mar 16 '18 at 14:47
3

The problem with adding these items to version control is, that different version of visual-studio, or perhaps other environments may generate these files in different ways. This sometimes leads to irritating conflicting errors on build servers ect.

VS can auto generate this file.

Spook Kruger
  • 367
  • 3
  • 15
  • 1
    Thanks for answer. I will paraphrase your answer for simplicity: **No need to store Settings.Designer.cs in VCS** – Janis Veinbergs Jun 02 '17 at 13:03
  • I changed the accepted answer to the another one, as experience with both options convinced me to put it under version control, which also corresponds to Microsoft practice as seen in the other answer. – Wilbert Apr 26 '18 at 12:36
0

After reading this answer, I went ahead and deleted the Properties/Settings.Designer.cs but got an error when building the project that "the file was missing". My project still had the references to it. So it is important that you also remove the references from the Project.

ldiablo
  • 67
  • 11