156

For apparently no reason, every time I open my solution, Visual Studio checks the sln file out.

If I compare it to the previous version there are no changes. But this is really frustrating since everybody has the solution checked out.

I'm using VS 2008 and TFS 2008, both SP2.

Any idea on how I can stop this thing to happen? Or is a feature/bug of the TFS source control provider for VS?

Jimmie R. Houts
  • 7,728
  • 2
  • 31
  • 38
CodeClimber
  • 4,109
  • 4
  • 32
  • 44
  • do you have a unit test project as part of the solution? – Mitch Wheat Jul 06 '09 at 08:29
  • 1
    TFS supports concurrent checkouts, and as long as there is not modification to the .sln file multiple checkout are not a problem. – Dirk Vollmar Jul 06 '09 at 08:30
  • @Mitch: no, we don't @divo: I know, but unfortunately this is not always true :) – CodeClimber Jul 06 '09 at 08:34
  • What kind of problems happen when the solution files are checked out from TFS? Coming from SVN (where a checkout happens on all files by default) I never worried about multiple checkouts when using TFS. – Dirk Vollmar Jul 06 '09 at 08:51
  • 5
    When *.sln files have actual changes, they are a horrific nightmare to merge because the projects within are given arbitrary-but-not-unique IDs. I'm a big advocate for concurrent checkouts, but I keep most of our *.sln locked. – Richard Berg Jul 06 '09 at 14:14
  • The problem is that merge on solutions files fails most of the times :) – CodeClimber Jul 06 '09 at 14:14
  • Yes, merging .sln files is indeed often a problem. But I don't see how preventing an automatic checkout would make merging the solution files easier. – Dirk Vollmar Jul 06 '09 at 15:04
  • i have the same problem and in addition solution checks out even if i get latest version, build solution etc. – Ozan BAYRAM Mar 17 '10 at 13:51
  • @0xA3 it allows you to put a lock on the solution so that you can guarantee that no on would have to merge the .sln file if you are making big changes. – felickz Aug 22 '12 at 19:08
  • 3
    THIS IS FIXED IN VS2013!!! I open same solution in 2012 and it checks out .sln, open in 2013 and it stays clear. – felickz Oct 23 '13 at 21:50
  • 2
    I have seen this from time to time with all versions back from Visual Studio 2010 and up to the newest version, Visual Studio 2015 Update 3. It happens around half of the times I open a solution, and it seems to be more frequent for solutions with many projects. – Tore Østergaard Sep 19 '16 at 13:45
  • "If I compare it to the previous version there are no changes." Lucky you. In my 2010 solution, it likes to randomly remove some SQL files from the "solution items" folder when I use Get Latest. – Medinoc Sep 11 '17 at 15:42
  • @Medinoc it sounds like your `.sqlproj` file is omitting those files. I wouldn't blame TFS on that one (I'd blame it not flushing changes to the file until you do a Save All operation (`Ctrl+Shift+S`), rather than a normal save (`Ctrl+S`)). You should fix the `.sqlproj` file once and for all by right-clicking the appropriate parent folders and doing `Add > Existing Files`. – Elaskanator Aug 20 '18 at 14:48
  • @Elaskanator In fact I didn't know sql projects existed; these files are just stuffed in Solution Items without being referenced by a project. – Medinoc Aug 20 '18 at 19:22

9 Answers9

122

This happens when the following is in the .sln file:

GlobalSection(ExtensibilityGlobals) = postSolution
    MyGlobalProperty = AnyValue
EndGlobalSection

I found that Enterprise Library added one of these. I removed it, checked in the solution, closed then re-opened it, and no more automatic check out.

Graham Clark
  • 12,886
  • 8
  • 50
  • 82
  • 21
    Looks like the Unity NuGet package may have done this to my solution file in VS 2010. I removed this section and my auto-checkout problem was solved. Thanks Graham! – Dan Mork Sep 20 '11 at 21:34
  • 14
    two of my favorite technologies - TFS and EntLib - what a pair of darlings. –  May 03 '12 at 07:54
  • 1
    I have such a section but do not want to remove it since it contains data I want to keep - what now? MS closed this issue as "not reproducible" - stupid? https://connect.microsoft.com/VisualStudio/feedback/details/573538/visual-studio-2010-with-tfs-2010-always-checks-out-the-solution-file-when-opening# – mattanja May 14 '12 at 07:06
  • Dan's comment adds the needed info -- it's not necessary to remove *all* global sections -- just the part that seems to get added in by the unity nuget package. – Jordan0Day Aug 13 '12 at 19:04
  • This works. I had a NuGet reference in a GlobalSection just as described in this answer. The solution file was checked out without any changes every time it was opened. Removed this section and the solution file is no longer checked out automatically. – JPRO Mar 14 '14 at 20:41
  • This section is not in my. sln file, and there are no Nuget packages installed in the solution. But VS _still_ checks out the .sln file all the time! Any ideas? (Running VS 2015 and TFS 2015) – CaptainStealthy Feb 15 '17 at 23:38
6

From memory, if you use the Tools, Options menu and select the Source Control, Environments panel there should be a few options for configuring the way the IDE interfaces with the version control.

I think some of these options control the checkout on open behaviour.

jussij
  • 10,370
  • 1
  • 33
  • 49
  • 1
    yes... they allow you to checkout automatically, prompt from checkout, or do nothing... but nothing that helps with this problem – CodeClimber Jul 06 '09 at 14:16
  • can't you then just say "no, don't check out" when it prompts you? – Scott Marlowe Jul 22 '09 at 17:53
  • I wish I was the only developer in the team... unfortunately I cannot rely an all developers being diligent – CodeClimber Jul 29 '09 at 09:06
  • CodeClimber, every time you start VS it does an automatic check out and you want that to stop and turning off the automatic check out does option not fix the issue. What the? – veight Apr 27 '13 at 00:47
  • 1
    For those who don't have the "Environments" in their list of options, change your connection from "Local" to "Server" (source: http://stackoverflow.com/questions/26843300/how-to-disable-auto-check-out-when-i-save-or-edit-file-tfs) – VenerableAgents Dec 31 '14 at 17:36
6

Just in case, like me, you couldn't get it to work and you find that one or more projects also get checked out, I found a simplier solution. Make a note of the project(s) that it keeps checking out. Go to File - Source Control - Change Source Control, and then unbind the projects in question. Click OK, Save All, then go back into Change Source Control and bind teh project back to the solution. Hopefully this will work for others

JJ76
  • 61
  • 1
  • 1
3

Allow the check-out and then compare both files. If VS added something like

<Service Include="{B4F97281-0DBD-4835-9ED8-7DFB966E87FF}" />

you are experiencing a VS bug with a solution in VS2008 but not ported to VS2005

Check this link for further details:

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Luis Filipe
  • 8,488
  • 7
  • 48
  • 76
3

Although not preventing the problem in the first place, liberal use of the Team Foundation Power Tools "Undo Unchanged" command will (surprise surprise) undo the pending edit if no changes have been made.

Dave Roberts
  • 537
  • 3
  • 7
  • Updated link for Team Foundation Power Tools: https://marketplace.visualstudio.com/items?itemName=TFSPowerToolsTeam.MicrosoftVisualStudioTeamFoundationServer2015Power – Jaider Dec 14 '16 at 19:28
2

The Visual Studio Solution file is being silently checked-out through one or more of the Solution's Projects using the Microsoft Enterprise Library - I believe this is something to do with the Enterprise Library Configuration Utility which allows the configuration management of the various Application Blocks - http://msdn.microsoft.com/en-us/library/ff649479.aspx

See this Microsoft Feedback posting: http://connect.microsoft.com/VisualStudio/feedback/details/737184/globalsection-extensibilityglobals-postsolution-checks-out-sln-file-on-open

Nigel Belham
  • 463
  • 3
  • 12
1

It is a feature/bug of one of the project systems being loaded within the solution. Try removing various types of projects (C#, VB, C++, web site, web app, unit test, silverlight...) until it goes away; that's your answer.

Richard Berg
  • 20,629
  • 2
  • 66
  • 86
0

Are you saving your files before do the comparison? It happened with me some time ago and keep saying there are no changes between the files, but after some time I realize I wasn't saving the files before and it was comparing with the version in disk, not the version in memory.

Every time you open some solution in Visual Studio, it performs some operations which may cause your .sln or project files change and then it will ask you to check out the file. It happens when there are changes in the folder structure in the developers machine, or when they don't have the same versions of all the files. Maybe someone added a project in some folder and another developer has the same project in another place. Another case I see this happen was when we have an solution with some c++ projects, for some reason, one of this c++ projects had a .res file with absolutes paths. Once this file was generated automatically by VS it kept change from developer machine to developer machine.

I would suggest you to open your .sln file and look for some absolute paths or by relative paths which may not exist in some developer machine, depending what files they Get from yours Source Control.

Carlos
  • 143
  • 2
  • 8
0

In Visual Studio 2019 / 2022 change the following settings

As demonstrated in this answer

https://stackoverflow.com/a/75814658/1165173

nimblebit
  • 473
  • 3
  • 11
  • 22