Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What parts of a Xamarin solution should be kept out of the repository?

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.

like image 556
Jannie Theunissen Avatar asked Aug 08 '13 06:08

Jannie Theunissen


2 Answers

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
like image 172
Lasse V. Karlsen Avatar answered Oct 30 '22 17:10

Lasse V. Karlsen


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).

like image 4
Rolf Bjarne Kvinge Avatar answered Oct 30 '22 18:10

Rolf Bjarne Kvinge