18

Visual Studio Solution files contain two GUID's per project entry. I figure one of them is from the AssemblyInfo.cs

Does anyone know for sure where these come from, and what they are used for?

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201
FlySwat
  • 172,459
  • 74
  • 246
  • 311

2 Answers2

17

Neither GUID is the same GUID as from AssemblyInfo.cs (that is the GUID for the assembly itself, not tied to Visual Studio but the end product of the build).

So, for a typical line in the sln file (open the .sln in notepad or editor-of-choice if you wish to see this):

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}"

The second GUID is a unique GUID for the project itself. The solution file uses this to map other settings to that project:

GlobalSection(ProjectConfigurationPlatforms) = postSolution
    {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
    {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
    {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
    {55A1FD06-FB00-4F8A-9153-C432357F5CAC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection

The first GUID is actually a GUID that is the unique GUID for the solution itself (I believe). If you have a solution with more than one project, you'll actually see something like the following:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleSandbox", "ConsoleSandbox\ConsoleSandbox.csproj", "{55A1FD06-FB00-4F8A-9153-C432357F5CAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Composite", "..\CompositeWPF\Source\CAL\Composite\Composite.csproj", "{77138947-1D13-4E22-AEE0-5D0DD046CA34}"
EndProject
Stephan Bauer
  • 9,120
  • 5
  • 36
  • 58
Jason Olson
  • 3,616
  • 2
  • 21
  • 24
  • any parsing in C# for sln file? It's a pity sln file is not XML format. @JasonOlson – Kiquenet Dec 03 '13 at 11:35
  • 8
    The first GUID identifies the project type, as (briefly) mentioned here -- http://msdn.microsoft.com/en-us/library/bb165951(v=vs.90).aspx. Also see http://www.mztools.com/Articles/2008/MZ2008017.aspx for a list of project types. (I'm still wondering if there's a special guid for a solution folder ...) – yoyo Dec 05 '13 at 20:20
  • 1
    Thanks for the link @yoyo. The folder GUID seems to be {2150E333-8FDC-42A3-9474-1A3956D46DE8}. – Giles Sep 16 '16 at 12:06
7

According to MSDN:

[The Project] statement contains the unique project GUID and the project type GUID. This information is used by the environment to find the project file or files belonging to the solution, and the VSPackage required for each project. The project GUID is passed to IVsProjectFactory to load the specific VSPackage related to the project, then the project is loaded by the VSPackage.

Shog9
  • 156,901
  • 35
  • 231
  • 235