Microsoft Visual Studio uses GUIDs to identify a Project Type. As mentioned in tekeye blog post:
This allows for developers in different companies to call projects by
the same name, but if they come across each other's work the same
named projects would still be uniquely identifiable by Visual Studio.
GUIDs generated for project types are placed in .csproj
file under ProjectTypeGuids
and .sln
file under Project
.
In .csproj
file:
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
In .sln
file:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFormsTestApp", "WindowsFormsTestAppWindowsFormsTestApp.csproj", "{F00515D6-939F-4E92-8FFD-A5D8F811FF84}"
You can find a complete list of GUIDs in Tekeye blog post linked above.
To grab this programmatically from .csproj
file you can use snippet below:
XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003";
XDocument projDefinition = XDocument.Load("projectPath\file.csproj");
IEnumerable<string> references = projDefinition
.Element(msbuild + "Project")
.Elements(msbuild + "PropertyGroup")
.Elements(msbuild + "ProjectTypeGuids")
.Select(refElem => refElem.Value);
If you didn't find ProjectTypeGuids
in .csproj
file, you can find Guid in .sln
file by parsing the file using regex as @watbywbarif did in this stack thread.