I work in a team on a Visual C++ project. Following advice we got we\'re tracking the project\'s .sln file with our SCM. It turns out that each time I pull from my partner (yes,
I've had the same problem. I finally noticed it came from a vcxproj file which didn't define its GUID. I manually added this GUID in my vcxproj file :
<PropertyGroup Label="Globals">
<ProjectGuid>{D3303AD3-B7E5-48F8-919C-18202ABAEF00}</ProjectGuid>
<RootNamespace>MyProject</RootNamespace>
<ProjectName>MyProject</ProjectName>
<Keyword>MFCProj</Keyword>
</PropertyGroup>
I had a difficult time finding this particular post when searching for the answer, so I just wanted to add some key words and explanation to make it easier to find. Thanks to the fantastic answers by Daniel and tgb I was able to resolve this issue and my team and I no longer have conflicting solution files after opening Visual Studio 2010 (I would vote their answers up, but I just joined today and do not yet have enough reputation points to vote answers up...).
So, to ask the question in a few more ways: Why does Visual Studio change .sln files when opening a solution? Why do .sln files have local modifications? or What causes merge conflicts in Visual Studio Solution files?
Answer: Most likely a different or missing ProjectGuid attribute in the .vcxproj Project file will cause local modifications. This could be due to upgrading projects from previous versions of Visual Studio or just from manually copying a project file and editing parts of it.
The fix is to add the line:
<ProjectGuid>{###}</ProjectGuid>
(with the appropriate ID from the solution file in place of ###) to the .vcxproj file in the 'PropertyGroup Label="Globals"' node, for example:
<PropertyGroup Label="Globals">
<ProjectGuid>{FD0675C0-EC06-E665-4001-12DEE6694605}</ProjectGuid>
<RootNamespace>MyProject</RootNamespace>
</PropertyGroup>
Otherwise Visual Studio will just assign a new random ProjectGuid to each project and update the .sln file. The 'ProjectGuid' can easily be found for a given project in the .sln file:
Project("{<Filter#>}") = "MyProjName", "src\to\Proj.vcxproj", "{<ProjectGuid>}"
That is a GUID which Visual Studio uses to refer to the individual projects. You will find the same GUID at the top of the .sln file, where the projects are defined/imported.
Visual Studio reads the GUID from the corresponding .csproj/.vbproj file. There you should find a ProjectGuid property near the top with the corresponding GUID. If you and your partner have a different GUID defined there, the .sln will also update.