dtc
dtc

Reputation: 10296

How do you handle VS.net sln and proj files in source control?

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?

Upvotes: 3

Views: 2215

Answers (6)

Tollo
Tollo

Reputation: 537

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.

Upvotes: 2

Joshua
Joshua

Reputation: 43197

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.

Upvotes: 0

RobS
RobS

Reputation: 9422

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.

Upvotes: 2

Robert Lewis
Robert Lewis

Reputation: 527

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

Upvotes: 3

chris
chris

Reputation: 37440

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.

Upvotes: 2

Brendan
Brendan

Reputation:

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.

Upvotes: 2

Related Questions