What are the project GUIDs in a Visual Studio solu

2019-02-02 02:08发布

问题:

I have multiple projects in a single Visual Studio (2008) solution.
I just discovered that each of these projects uses a same GUID, so in the solution file it looks like this:

Project("{FAE04EC0-F103-D311-BF4B-00C04FCBFE97}") = "Pro1", "Pro1\Pro1.csproj", "{...}"
Project("{FAE04EC0-F103-D311-BF4B-00C04FCBFE97}") = "Pro2", "Pro2\Pro2.csproj", "{...}"

Do I have to change these GUIDs so they're unique and what are they used for?

回答1:

Project persistence block in a solution file has the following format:

Project("{project type GUID}") = "<Project name>", "<project file location>", 
    "{<Unique project GUID>}"
EndProject

So it's expected that first GUID is non-unique, it uniquely identifies Visual Studio package that handles this type of projects.

The GUID you posted is interesting - it looks like mangled C# project GUID, which is FAE04EC0-301F-11D3-BF4B-00C04F79EFBC. Did you change it yourself or is it a posting issue (e.g. you are using right-to-left locale such as Hebrew or Arabic).



回答2:

I will often copy a VS project file, rename it and search and replace all occurrences of the project name to create a new project with same settings. This is often quicker than creating a new project and then ensuring all the settings are correct. I ignore the GUID. VS will change the GUID as soon as I save the project after adding it to solution.

I do a lot of DLL/C/C++ development and I have deviated from the standard project settings extensively over the years (particularly in regard to optimization, code generation etc) and I find the copy technique a quicker, surer way of setting up a project.



回答3:

The first guid is the project type. Project type guids can be found here...

http://www.codeproject.com/Reference/720512/List-of-Visual-Studio-Project-Type-GUIDs



回答4:

The project guids in the csproj file should be unique. From my experience if two csproj files are included in the same solution visual studio automatically regenerates one of the guids.



回答5:

Word to the wise: If making an XBOX360 XNA 4.0 project and trying this trick, Don't use a guid generated by VS 2012. generate one in VS2010 and use that.

Or you will get the following error when you try to run your re-guid'ed project in XNA Game Studio Connect.

"This game is missing or corrupt, blah blah blah, restart XNA Game Studio Connect?"

and then it will bomb. VS 2010 guids work fine. I have no idea why.