public override int OnBeforeCloseProject(IVsHierarchy hierarchy, int removed)
{
if(removed != 0)
{
List<ProjectReferenceNode> projectReferences = this.GetProjectReferencesContainingThisProject(hierarchy);
foreach(ProjectReferenceNode projectReference in projectReferences)
{
projectReference.Remove(false);
// Set back the remove state on the project refererence. The reason why we are doing this is that the OnBeforeUnloadProject immedaitely calls
// OnBeforeCloseProject, thus we would be deleting references when we should not. Unload should not remove references.
projectReference.CanRemoveReference = true;
}
}
return VSConstants.S_OK;
}