Skip to content

Instantly share code, notes, and snippets.

@citizenmatt
Created January 19, 2016 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save citizenmatt/c30645222bc48bb2b085 to your computer and use it in GitHub Desktop.
Save citizenmatt/c30645222bc48bb2b085 to your computer and use it in GitHub Desktop.
De-duplicate msbuild references
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- For some reason, msbuild will sometimes duplicate all references in @(ReferencePath),
which, given a particularly meaty nuget package (*cough*JetBrains.ReSharper.SDK*cough*),
can overwhelm the command line. This little hack will de-duplicate references to
reduce the pressure, but it's still going to hurt at some point...
I'd really like to figure out why msbuild is duplicating. Given a simple test with
just e.g. nunit, it works as expected. Perhaps it's something to do with the ReSharper
SDK nuget, but I can't see it -->
<PropertyGroup>
<CoreCompileDependsOn>
$(CoreCompileDependsOn);
_RemoveDuplicateReferences
</CoreCompileDependsOn>
</PropertyGroup>
<Target Name="_RemoveDuplicateReferences">
<ItemGroup>
<_DeduplicatedReferencePath />
</ItemGroup>
<RemoveDuplicates Inputs="@(ReferencePath)">
<Output TaskParameter="Filtered"
ItemName="_DeDuplicatedReferencePath"/>
</RemoveDuplicates>
<ItemGroup>
<ReferencePath Remove="@(ReferencePath)" />
<ReferencePath Include="@(_DeduplicatedReferencePath)" />
</ItemGroup>
</Target>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment