views:

531

answers:

7

I hope this qualifies as programming related since it involves how to structure a project.

Because I've always used the web site model with VS.net I never had solution and project files and putting everything into source control worked great. I knew that everything I had in my web site directory was all I needed for the web site.

Now I'm using asp.net MVC and it only has a project model so now I have these solution and project files. If I work on it alone it's fine but once other people start to add/delete files from the project our solution file gets messed up and people end up having to grab the latest solution file, see what got changed and then add back/remove their files and check in the solution file again. It's become sort of a problem because sometimes people don't realize the solution file was changed, they make other changes and then when they check in everything other people do an update on their files they find that their files are gone from the project (although still physically on disk).

Is this normal? Is there a way to structure a project so that we don't need to check in solution and project files?

+1  A: 

This tends to happen with TFS multiple check outs. It can be hard to grasp coming from VSS to TFS as VSS allowed one person to check a file out at one time. Auto-merge should work most of the time for you but a couple of rules should ease the pain:

  1. Check in early and often (if you add remove or rename a file check it in straight away even if it is a blank holder)
  2. Before you check in do a get latest, this will ask you to resolve conflicts locally

Try to get continuous integration set up so that developers always know the state of the buidl and whether it is OK to check in\out.

We had a bit fo pain at the start of our current project but it soon settled down when we followed the rules above.

Thanks for the good pointers about checking in often and continuous integration.
metanaito
+2  A: 

I don't think it's normal - what are you using for source control? It sounds like developers aren't respecting changes that others a making - checking in without merging first.

I know that early on in a project, when lots of files are being added & deleted, it can be a problem to keep up - you need to check out the project file, add your files, then check in the new file & project so other developers can also update it. You'll probably have multiple project files in a solution - perhaps one interim solution would be to have one "holding" project for each developer, then clean them up periodically - though these types of temporary fixes do have a tendency to become permanent.

I don't know of a way to set up a project file that's not in source control, though I suppose you could create a script that would generate them.

Having been through this, the key is respect & good communication between the developers.

chris
We are using SVN and TFS and have the same problem with both. The problem usually comes up when someone forgets to check stuff in or don't notice that they have sln and proj files checked out.
metanaito
Well, you've just identified the problem. If communication is an issue, perhaps you could turn on svn notifications, so email is sent whenever a file is committed.Although I've see times when Visual Studio "helpfully" checks out a file for you, silently, so it may not always be the developers fault.
chris
+2  A: 

Your developers are not using TFS correctly. You should have multiple check-outs turned on, and everyone needs to be careful to merge their changes correctly when checking in. TFS will prompt you to do this, and accepting the defaults is nearly always the right thing to do.

It's not uncommon to have one or two developers who never get it, and you might have to help them now and then. But every programmer who works on a team needs to learn how to use source control tools correctly. If they can't manage that, they shouldn't be writing software.

[edit] It occurs to me that you might run into these problems if you check in the *.sln file directly, rather than choosing to "Add Solution to Source Control".

Robert Lewis
Yes, it appears we don't have a good procedure in place. One problem is that developers don't notice they've checked out a solution or project file. Also some only check in files they checked out and don't look at the solution level. Get latest > Check in at the solution level would probably solve a lot of problems we have.
metanaito
+1  A: 

Personally, I think making changes to project and solution files requires discipline and clear (well understood) rules throughout your development team. These files (.sln, .*proj) are the bottlenecks of your project, and any errors or inconsistencies can cost you in team downtime. Changes need to be well thought out, planned and then executed.

They must be secured by source control (which you're already using, excellent) and your team members should work on the basis of only making the changes they need, and not leaving project or solution files checked out for an extended period.

If you are allowing multiple (shared) checkouts, this could become problematic in terms of overwriting another user's changes. Depending on your source control mechanism, people may be required to manually merge changes. Personally, I'd ask people to negotiate their project/solution changes with each other over merging (this can't always be achieved).

A third option if you are using TFS is the shelve feature. If someone needs to make changes locally, they can shelve the changes and merge later.

Lastly, another strategy is to try to architect your solution to be as modularized as possible - so people are distributed, working on separate projects and do not (ideally) have to overlap on too many common areas.

RobS
A: 

Always check them in.

Always check out latest (merge if possible), make sure your change is there, before checking in a new version.

If your source control doesn't require a special action to check in from an old version, GET A DIFFERENT SOURCE CONTROL.

Joshua
+1  A: 

I'm not sure if you are using TFS, as people have mentioned, but if you are (or if you are using source control with similar capabilities) you can set it such that sln and csproj files are exclusive lockouts and are not able to be merged.

We have done this with quite large teams and while it causes some initial issues as people get used to it in the long run it has resolved many issues that were previously causing problems. Essentially you trade longer term merge issues/complexity for short term compile/checkin issues which we have found to be a good trade off.

Once you have set it to forced exclusive checkout and no merge you then get your dev teams used to the fact they should keep locks on the sln and proj files for as shorter time as possible.

Tollo
I think I like the idea of the solution and project files being exclusive check outs. I'll have to see if SVN allows this (We use TFS and SVN for different projects).
metanaito
A: 

I realise that this thread may be dead but I thought I'd wake it up again as I can't find a solutino.

I work with a small, experienced team that know how to use source control, TFS, but we are forever frustrated with the fact that TFS will exclusively check out a proj file when adding/removing/renaming a file.

We use Beyond Compare for our merging tool which again, we are very experienced with, and we know the structure of the proj file, so we want the control to manually merge a proj file.

The big reason for this is the fact that we use Shelvesets often. But as soon as you have the proj file exclusively locked, the concept of the shelveset goes out the window. You can't work in your own space, writing all you code, testing, preparing your code, using shelvesets as you go so that when you merge it gets done as one changeset. Ie you are working on a new peice of functionality, which may take you days/weeks to get ready before you want to commit your change, but if you are adding/removing files (as you tend to do when creating new functionality) you have to commit changes before you are ready for them to be committed, potentially introducing bugs that you don't want to have to deal with at that time.

I realise that the proj file is an important part of the solution and therefore MS may have deemed this too important to allow multi-check outs on, but give me the option to accept that responsibility. Like I said we are experienced.

Mind you, if this is an option, can someone please let me know how to enable it :), and before you ask, yes we have the Enable multiple check-out option enabled.

Brett Morris