Visual-studio – Project GUID keeps changing

msbuildvisual studiovisual-studio-2008

We have a VS2008 solution and i've noticed something weird happening:

some projects refer other projects that are defined in the same solution (added as project references). This was done some time ago.

Building straight from VS works fine.

Building from MSBUILD fails.

I have removed the project reference and re added it, and i've noticed that the project's GUID is changed. Building from MSBUILD now works.

Problem is, i now have to go over all projects and verify this.

Moreover, i have no idea why this occured (why is the project GUID different from what it was before, and not sure if this may happen again).

What could be the cause of this?

Best Answer

I also see this problem in Visual Studio 2013, and it does not require Source Control integration to occur.

It happens to me occasionally when I have the same project in multiple solutions, each solution uses a different GUID for that project, and updates the project accordingly. The solution is to manually modify the .sln files to get them in sync. Credit for this answer goes to Chunsheng Tang.

First open the solution file (.sln) with notepad and check out the project references there. The format is like this:

     # Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsApplication1", "WindowsApplication1\WindowsApplication1.csproj", "{9378D255-CE38-45CD-82FA-A1EBFB86FD6C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary1", "ClassLibrary1\ClassLibrary1.csproj", "{DE374096-FF44-4FDF-B248-C767039B4175}"
EndProject

The second GUID for each project is the reference to the shared project.

To solve the problem, select a single GUID for your shared project; Make sure all the solutions that open it have that single thus the same GUID in their solution files. (Please backup your files before making these changes)

https://social.msdn.microsoft.com/Forums/en-US/1d632940-cc1d-49d5-a64c-d3e999216cbd/cant-avoid-the-projectguid-from-being-changed-in-csproj-file?forum=csharpide