locked
Can't Avoid the ProjectGuid from Being Changed in .csproj File RRS feed

  • Question

  • This is not strictly an issue with VS2005 and VSS, altho it only becomes an issue when using some kind of source control.  The nut of the problem is that I have two projects in a solution of about a dozen projects where the ProjectGuid in the .csproj field is changed simply by virtue of the solution being opened in VS2005 (SP1).  There are also other solutions containing the same projects which manifest the same behavior.

    This has become a significant nuisance because when using VSS, it requires me to check out the csproj files upon opening the solution.  Other than the hassle, I try to avoid checkout/checkin of these project files because they do not merge well, and thus I prefer checkouts of these only when necessary to add files or change settings.  It seems somewhat pointless to keep churning the ProjectGuid for no apparent reason.

    We are now in the midst of a transition to Subversion, and the same behavior manifests in that environment, it's just that since SVN does not do any real checkout a la VSS, these csproj files just keep changing on every VS2005 start, and SVN flags these for commital to the repository.

    Hence, I don't think this is an issue with VSS (or SVN), but rather a VS2005 issue, but one that only is of concern when you care about how files are changing as you work.

    For some more specifics, these two projects are both for C# DLLs, and they are referenced by other DLL and EXE projects within these solutions.  I have probably another dozen or so DLL projects that do not exhibit this quirk, and it is always the same two projects that have this among the several solutions I reference them in.

    This seems to have started a few months ago when I restructured the source tree within VSS and moved all of the SLN files to the root node of the tree.  This resulted in virtually all the references to the sub projects needing to be re-pointed from the Settings tab within VS2005.  I don't think anything was unusual about these two projects during that change,

    I've searched the web/forums quite a bit, but this does not seem to show up in my results.  So if anyone has any suggestions of what to try or where to look, it would be most appreciated.


    Tuesday, February 5, 2008 12:07 AM

Answers

  • Did you mean the ProjectGuid was changed when it was opened in another solution?

     

    That’s caused by multiple solutions has different references to the shared project, so whenever you save a solution that opens a project, the solution apply it's own reference (GUID) to the project file(.csproj).

     

    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 GUID in red 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 any change.)

     

    Best Regards

    Chunsheng Tang

    Thursday, February 7, 2008 6:48 AM
    Moderator

All replies

  • As you've noticed, this is not a source control issue per se.  I'm moving it to the VC# IDE forum where hopefully you can get an answer from the developers of the C# project system.
    Tuesday, February 5, 2008 6:48 PM
  • Did you mean the ProjectGuid was changed when it was opened in another solution?

     

    That’s caused by multiple solutions has different references to the shared project, so whenever you save a solution that opens a project, the solution apply it's own reference (GUID) to the project file(.csproj).

     

    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 GUID in red 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 any change.)

     

    Best Regards

    Chunsheng Tang

    Thursday, February 7, 2008 6:48 AM
    Moderator
  • Thanks, this seems to have solved my problems.
    Monday, February 11, 2008 8:58 PM
  • First of, I can confirm that the same issue still exists in VS 2008 and I am sure VS 2010 isn't any better (untested).

    While this may be a minor annoyance with source repositories it really starts to complicate things when you create project templates. Try to enforce the GUID of a project when you generate it using a template! I have coupled my template with a wizard dll and still cannot do anything about the guids going to ____. Even if you place a guid in the ProjectGuid tag with parameter replacement it will always get changed when the solution is saved. I guess the solution file is for some reason always out of sync with the generated guid of the project so there is simply no way to generate smart templates for multi-project solutions.

     It seems the solution file is written to the HDD after the wizard is fully decoupled from the project. So I cannot even do manual string replacement fixups from my dll.

    This means that I will want to create the multi-project solution out of my template, I will have to close the visual studio, fire up a text editor, fish out all the GUIDs from projects and update them in my solution and setup projects. Uuuuh!

    Why are Project GUIDs even used in solution files, as you always have to provide the path to the project files. And if they have to be there, why not update the GUID in the solution with the GUID retrieved from the project and not vice versia. Projects are the important files. Solutions are just sticky stuff that groups projects together.

    Thursday, March 25, 2010 1:57 PM
  • Hi,

    Was Omahenas problem solved?

    Arjun

    Monday, July 19, 2010 3:08 PM