22

After I add 2 libraries from Nuget to my project I receive follow error:

Error       Payload contains two or more files with the same destination path 'System.Diagnostics.Tools.dll'. Source files: 
C:\Users\Horcrux7\.nuget\packages\runtime.any.System.Diagnostics.Tools\4.0.1\lib\netcore50\System.Diagnostics.Tools.dll
C:\Users\Horcrux7\.nuget\packages\System.Diagnostics.Tools\4.0.0\lib\netcore50\System.Diagnostics.Tools.dll App1            

How can I solve this version conflict?

I have only a very small single UWP project.

Horcrux7
  • 23,758
  • 21
  • 98
  • 156
  • Are you referencing some prerelease nuget packages? – Jackie Jul 30 '16 at 04:33
  • I add 2 references to 2 different libraries which are compiled again different versions. This should not be very exotic. There should be a general construct to solve this conflicts. – Horcrux7 Aug 01 '16 at 07:51
  • Maybe you can consider downgrading one of your referenced libraries. I'm seeing the same error reference System.Net.Sockets 4.1.0. However, after downgrade to 4.0.0, everything works fine. – Jackie Aug 01 '16 at 09:01
  • No, downgrade is not possible because older versions are not compatible with UWP. – Horcrux7 Aug 01 '16 at 09:21
  • Did you find this thread http://stackoverflow.com/questions/31851012/unable-to-load-dll-sqlite3-in-universal-windows-app-running-on-mobile userful? Does not seem like a good solution, but works for me. – Jackie Aug 02 '16 at 01:19
  • This is not a solution. First it must be do on every system. Also on a the central build system. To replace files in the nuget package manager seems also a bad idea. The second answer with filtering does not help because there is no the duplicated references to see. – Horcrux7 Aug 02 '16 at 14:35

9 Answers9

21

The problem has solve it self. An update to the latest version of Microsoft.NETCore.UniversalWindowsPlatform has solved it.

It look like that library A was compiled against version 5.1.0 and library B was compiled against version 5.2.2. Because my project was on version 5.1.0 there was a conflict situation. I does not understand why I have no conflict if I switch the UWP version.

If I use the library B with the old UWP version there was also no conflict.

Horcrux7
  • 23,758
  • 21
  • 98
  • 156
  • I had exactly the same problem. Same DLL. Same 5.1.0/5.2.2 conflict. I was surprised that this version mismatch is not solved by Visual Studio / nuget by updating Microsoft.NETCore.UniversalWindowsPlatform to 5.2.2 at package install/restore time. – Frank Rem Aug 29 '16 at 14:30
14

Just in case it may be useful to others encountering the same error - "Payload contains two or more files with the same destination path..." - which can be caused by a variety of reasons related to the labyrinth of NuGet packages, one remedy for such NuGet related errors is clearing the cache, or simply deleting the problematic NuGet package folder: C:\Users\user\.nuget\packages\

This is based on my own experience of dealing with similar errors including this particular one.

Edit (2018-07-22): I have been having good luck in dealing with this and similar problems by simply restarting Visual Studio. Probably Microsoft is getting to this bug finally. I get this kind of problems only when building a release version.

Hong
  • 17,643
  • 21
  • 81
  • 142
  • I do the same think and it's only one what's help me but i got other difference in path than package version incompatibility – W0RT4 Feb 08 '18 at 09:11
  • 4
    @W0RT4 It happens repeatedly when I build a release version of a UWP app. I now delete only C:\Users\user\.nuget\packages\microsoft.netcore.portable.compatibility, and it always works. I need to find a permanent solution. – Hong Feb 08 '18 at 10:39
  • 1
    try to remove project.nuget.targets file in my case it helps (i hope permanently) – W0RT4 Mar 13 '18 at 11:35
  • 1
    I got this error while building a release version, using VS 2019 version 16.2.3, even though nuget packages for all references were latest. But I was running other project in which I had an older nuget package. I closed that project and then I could create the package successfully. – Ritesh Patel Sep 08 '19 at 19:55
6

In my case, I had "Any CPU" option selected so it was compiling the same library for both versions. Selecting x64 solved the problem for me.

Usman Afzal
  • 376
  • 3
  • 9
  • 1
    I was getting this on a Xamarin.Forms UWP project release build and had a similar issue. The project properties Build section had x64 selected while I was trying to build/run as x86. Matching the two settings as, Usman pointed out, cleared the issue. – Sean Anderson Dec 12 '19 at 06:15
  • I also encountered this issue on UWP and MVVM cross. – Usman Afzal Jan 31 '20 at 20:59
3

I did a downgrade Microsoft.EntityFrameworkCore.Sqlite to 2.2.6 then solved problem.

2

You may try the following in VS2019

  1. Update Microsoft.NETCore.UniversalWindowsPlatform using Tools-->Nuget Package Manager--> Manage Nuget Package for Solutions

  2. Tools-->Nuget Package Manager--> Package Manager Settings-->Clear All Nuget Cache(s)

  3. Delete the files under:

<package Name>\bin\x86\Release
<package Name>\bin\x64\Release
<package Name>\bin\Arm\Release
  1. Build--> Clean Solution for each version, Release x86 etc

Finally worked for me. If this still fails, building a package using VS2017 may work.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Sam
  • 61
  • 4
1

I am using Microsoft.NETCore.UniversalWindowsPlatform version 6.2.12

My project was at D:\

Problem solved when I moved project to C:\

I didn't understand the cause though :( Path at D:\ was a short and all ASCII path.

t.m.
  • 1,430
  • 16
  • 29
0

update the Microsoft.EntityFrameworkCore.Sqlite version 3.1.2 solved my issue.

siva
  • 67
  • 5
0

For Default.rd.xml, I removed the duplicate from my Unit Test project and then was able to run my tests.

Michael Hawker - MSFT
  • 1,572
  • 12
  • 18
0

For me I had 2 instances of visual studio. I closed both and re-opened the project that I needed to publish and the error went away.

LLai
  • 13,128
  • 3
  • 41
  • 45