From cb181df7689f7e34af5c217684f8f198c009f421 Mon Sep 17 00:00:00 2001 From: Dustin Campbell Date: Thu, 6 Apr 2017 04:21:15 -0700 Subject: [PATCH] Ensure that MSBuildProjectSystem doesn't add project references twice It's possible for project references to appear twice within an MSBuild project after execution: * As a ProjectReference item * As a ReferencePath item with ReferenceSourceTarget="ProjectReference" This change makes sure that ReferencePath items that were sourced from project references aren't added. We just use the project references, which is a better experience at designtime when the project is built. --- src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs index db6af30d7d..e03db09d0e 100644 --- a/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs +++ b/src/OmniSharp.MSBuild/ProjectFile/ProjectFileInfo.cs @@ -218,7 +218,8 @@ public static ProjectFileInfo Create( var projectAssetsFile = projectInstance.GetPropertyValue(PropertyNames.ProjectAssetsFile); var sourceFiles = GetFullPaths(projectInstance.GetItems(ItemNames.Compile)); - var references = GetFullPaths(projectInstance.GetItems(ItemNames.ReferencePath)); + var references = GetFullPaths( + projectInstance.GetItems(ItemNames.ReferencePath).Where(ReferenceSourceTargetIsNotProjectReference)); var projectReferences = GetFullPaths(projectInstance.GetItems(ItemNames.ProjectReference)); var analyzers = GetFullPaths(projectInstance.GetItems(ItemNames.Analyzer)); @@ -231,7 +232,12 @@ public static ProjectFileInfo Create( sourceFiles, references, projectReferences, analyzers, packageReferences); } - private static IList GetFullPaths(ICollection items) + private static bool ReferenceSourceTargetIsNotProjectReference(ProjectItemInstance item) + { + return item.GetMetadataValue(MetadataNames.ReferenceSourceTarget) != ItemNames.ProjectReference; + } + + private static IList GetFullPaths(IEnumerable items) { var sortedSet = new SortedSet(StringComparer.OrdinalIgnoreCase);