Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget, portable library and WinRT appx: Payload contains two or more files with the same destination path

  1. Create new Windows 8 application App1
  2. Add ClassLibrary1 Windows 8 class library project to solution
  3. Add PortableClassLibrary1 portable class library targeting Windows 8 and Windows Phone 7.5 to a solution
  4. Reference HttpClient nuget package in ClassLibrary1
  5. Reference HttpClient nuget package in PortableClassLibrary1
  6. Reference both ClassLibrary1 and PortableClassLibrary1
  7. Compile solution

You get an error at .appx package stage

Payload contains two or more files with the same destination path 'System.Net.Http.Primitives.dll'. 
Source files: 
\Projects\App1\PortableClassLibrary1\bin\Debug\System.Net.Http.Primitives.dll
\Projects\App1\packages\Microsoft.Net.Http.2.2.13\lib\win8\System.Net.Http.Primitives.dll

Please note the same error is reproduced if you reference any nuget package featuring both win8 and portable blends of assemblies.

What is expected: Most specific version of a library (win8 one) is packaged into .appx and portable version is ignored

Any ideas on how to cheat appx packager and build this kind of Windows 8 projects?

like image 500
kza Avatar asked Aug 22 '13 10:08

kza


2 Answers

It looks like the solution described here works: http://cyanbyfuchsia.wordpress.com/2013/05/03/payload-contains-two-or-more-files-with-the-same-destination-path/

Basically, you must set "Copy local" to false in the WinRT project that is referenced from the main app.

like image 122
japf Avatar answered Sep 20 '22 07:09

japf


In addition to this, you should be getting warnings similar to:

All projects referencing ClassLibrary1.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.

This is indicating a problem. Basically, the short of it, you should be installing HttpClient.Compression into all projects. MSBuild/AppX packaging doesn't know which binary to deploy between the portable library and store library project (they have different APIs & versions). Installing the package into the application, tells it.

like image 2
David Kean Avatar answered Sep 21 '22 07:09

David Kean