protected virtual void SetProjectItemsThatRelyOnReferencesToBeResolved(bool renameItemNode)
{
// Call MSBuild to build the target ResolveComReferences
bool success;
ErrorHandler.ThrowOnFailure(this.ProjectManager.BuildTarget(MSBuildTarget.ResolveComReferences, out success));
if(!success)
throw new InvalidOperationException();
// Now loop through the generated COM References to find the corresponding one
IEnumerable<ProjectItem> comReferences = this.ProjectManager.BuildProject.GetItems(MSBuildGeneratedItemType.ComReferenceWrappers);
foreach (ProjectItem reference in comReferences)
{
if(String.Equals(reference.GetMetadataValue(ProjectFileConstants.Guid), this.typeGuid.ToString("B"), StringComparison.OrdinalIgnoreCase)
&& String.Equals(reference.GetMetadataValue(ProjectFileConstants.VersionMajor), this.majorVersionNumber, StringComparison.OrdinalIgnoreCase)
&& String.Equals(reference.GetMetadataValue(ProjectFileConstants.VersionMinor), this.minorVersionNumber, StringComparison.OrdinalIgnoreCase)
&& String.Equals(reference.GetMetadataValue(ProjectFileConstants.Lcid), this.lcid, StringComparison.OrdinalIgnoreCase))
{
string name = reference.EvaluatedInclude;
if(Path.IsPathRooted(name))
{
this.ProjectRelativeFilePath = name;
}
else
{
this.ProjectRelativeFilePath = Path.Combine(this.ProjectManager.ProjectFolder, name);
}
if(renameItemNode)
{
this.ItemNode.Rename(Path.GetFileNameWithoutExtension(name));
}
break;
}
}
}