public virtual void LoadReferencesFromBuildProject(MSBuild.Project buildProject)
{
foreach(string referenceType in SupportedReferenceTypes)
{
IEnumerable<MSBuild.ProjectItem> refererncesGroup = this.ProjectManager.BuildProject.GetItems(referenceType);
bool isAssemblyReference = referenceType == ProjectFileConstants.Reference;
// If the project was loaded for browsing we should still create the nodes but as not resolved.
if(isAssemblyReference && this.ProjectManager.Build(MSBuildTarget.ResolveAssemblyReferences) != MSBuildResult.Successful)
{
continue;
}
foreach (MSBuild.ProjectItem item in refererncesGroup)
{
ProjectElement element = new ProjectElement(this.ProjectManager, item, false);
ReferenceNode node = CreateReferenceNode(referenceType, element);
if(node != null)
{
// Make sure that we do not want to add the item twice to the ui hierarchy
// We are using here the UI representation of the Node namely the Caption to find that out, in order to
// avoid different representation problems.
// Example :<Reference Include="EnvDTE80, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
// <Reference Include="EnvDTE80" />
bool found = false;
for(HierarchyNode n = this.FirstChild; n != null && !found; n = n.NextSibling)
{
if(String.Equals(n.Caption, node.Caption, StringComparison.OrdinalIgnoreCase))
{
found = true;
}
}
if(!found)
{
this.AddChild(node);
}
}
}
}
}