18

I'm working with a designer on a Xamarin.Android application and we are having trouble keeping in sync. We use Mercurial, but my question should be as relevant for Git or any other DVCS. My .hgignore file looks like this:

^bin/
^obj/
^Components/
\.keystore$

I am unsure about these files:

^Resources/Resource.designer.cs
\.sln$
\.userprefs$
\.csproj$

Thanks!

Update
Found this great community wiki that confirmed excluding *.pidb and *.userprefs and by implication confirms including *.sln and *.csproj
See: .gitignore for Visual Studio Projects and Solutions

I'm not sold on including the Resource.designer.cs file. It gets automatically regenerated after changes to resources and it includes this notice:

// ------------------------------------------------------------------------------
//  <autogenerated>
//      This code was generated by a tool.
//      Mono Runtime Version: 4.0.30319.17020
// 
//      Changes to this file may cause incorrect behavior and will be lost if 
//      the code is regenerated.
//  </autogenerated>
// ------------------------------------------------------------------------------

With a merge you might reject an id name change in a layout file, but accept this file containing the new name.

Community
  • 1
  • 1
Jannie Theunissen
  • 28,256
  • 21
  • 100
  • 127

2 Answers2

18

To answer your question, you're wondering about this:

^Resources/Resource.designer.cs
\.sln$
\.userprefs$
\.csproj$

The Resource.designer.cs file should definitely not be ignored. Sure, it'll get regenerated in some cases, especially if you alter the resx file it is generated from, but just committing it to version control removes that hassle from everyone else, they don't need to regenerate it.

The .sln and .csproj files should definitely not be ignored. The solution file contains which projects are part of the solution, and the csproj file contains the project information, both of which you definitely need to commit.

.userprefs however is a local file, it contains the user preferences for the user using the machine, you do not want that in version control.

Here is my own Xamarin ignore file, with comments below:

syntax: glob
_ReSharper.*/
[Bb]in/
[Oo]bj/
*.user
*.userprefs
*.suo
.DS_Store

The first line tells Mercurial to use glob library to handle file masks.

The next line ignore ReSharper temporary files, which are added to their own subdirectory according to project or solution name. Note that you can ask ReSharper to use the temp folder on the machine for this, instead of storing it in the solution directory, but this may be a per-user setting so to ensure those folder doesn't accidentally gets committed, just ignore that folder.

Then I ignore bin and obj folders, handling both upper and lowercase first letter, ie. Bin is ignored, as well as bin.

Then I ignore everything with the extension user, userprefs, and suo, since all of those store local user preferences.

The last entry ignore the Mac resource folder.

If you have NCrunch, TeamCity, or FinalBuilder, there are additional entries you would probably want to add:

_NCrunch_*/
_TeamCity.*/
*.fb7lck
*.fbl7
*.fbpInf
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
  • 2
    Confused why you say the Resource Designer file _should definitely not be ignored_ and then proceed to say that it's simply for convenience rather than any fatal error to the rest of the team. Basically, you're saying it should be committed just so the other team doesn't have to do another build? That doesn't sound like _should definitely not be ignored_ to me. – JcKelley Nov 21 '14 at 21:20
  • This sample gitignore is very useful for Visual Studio 2015 projects based on Xamarin. I have also used it with Xamarin Studio projects. Should be informative since Xamarin is included in VS 2015. https://github.com/github/gitignore/blob/master/VisualStudio.gitignore – brady321 Apr 01 '16 at 15:32
  • 2
    I disagree with the resource.designer file being ignored, it causes merge conflicts constantly, and it doesn't save anyone any work because you still have to build and run the application when you pull it from source control, and at that point the file gets re-generated on build, what does it save a team member to have this file in source control? – Trevor Hart Jul 30 '17 at 03:06
4

This is pretty much how my .gitignore files look like:

*.pidb
*.userprefs
bin
obj
.DS_Store
*.suo

In more general terms those are the files you don't need (and as a consequence you do need the rest of the files).

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • Thanks for reminding Mac users of .DS_Store, Visual Studio users of .suo and Monodevelop users of .pidb http://stackoverflow.com/questions/1022111/what-are-monodevelops-pidb-files – Jannie Theunissen Aug 08 '13 at 12:29
  • On your lead, I also found this to confirm excluding .suo http://stackoverflow.com/questions/72298/should-i-add-the-visual-studio-suo-and-user-files-to-source-control – Jannie Theunissen Aug 08 '13 at 12:31