Hi all,
I am writing a VSPackage in C#. I need to get the Guid of a project which may be unloaded (so iterating over the Solution.Projects collection is not an option). Basically, I would like to do something like this:
uint numProjects;
sln.GetProjectFilesInSolution(0,0,null,out numProjects);
if (numProjects > 0)
{
projGuids = new List<Guid>();
string[] projectNames = new string[numProjects];
sln.GetProjectFilesInSolution(0,numProjects,projectNames,out numProjects);
foreach (string projName in projectNames)
{
projGuids.Add(GetGuidByProjectName(projName));
}
}
The crux is that I have not found any documented way to get the Guid from the names/strings returned by the Solution.GetProjectFilesInSolution method.
I know that I can retrieve the Guid via the UniqueName property of a Project instance, however, as I pointed out, some projects may not be loaded, and hence the Project instance is not available. After some debugging, I have found that the UniqueName property seems to be the path of the project file relative to the solution base directory. I could probably build some helper function to strip the base directory name from the project file path, and then use that to get the Guid, but I figure there must be some easier (cleaner) way.
I would appreciate any pointers here.
BR,
Matthias