microsoft-ui-xaml: Error in Create App Packages for Microsoft Store from a .wapproj

Describe the bug Creating app packages for MS store using a Packaging project with a UWP app fails with an error about Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png

Steps to reproduce the bug

Steps to reproduce the behavior:

  1. Create a new solution.
  2. Add a new UWP app
  3. Add a dependency on the Nuget package Microsoft.UI.Xaml.2.5.0-prerelease.201027002
  4. Add a new UWP project of type Windows Application Packaging Project called Package
  5. Add the UWP app project to the Package project, and make it an entry point
  6. Publish the Package project under a MS developer account using Create App Packages
  7. Select Microsoft Store option, and use a reserved app name.
  8. Set options to never generate an app bundle, select only x64 architecture, and click Create.
  9. Observe the following errors in the output console
1>Package -> C:\Users\MyUser\source\repos\App1\Package\AppPackages\Package_1.0.6.0_x64_Test\Package_1.0.6.0_x64.msix
1>C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64\MakeAppx.exe pack /l /h sha256 /f obj\x64\Release\upload.package.map.txt /o /p C:\Users\MyUser\source\repos\App1\Package\bin\x64\Release\Upload\Package_1.0.6.0_x64\Package_1.0.6.0_x64.msix  
1>You can't add both "C:\Users\MyUser\source\repos\App1\App2\bin\x64\Release\Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png" and "C:\Users\MyUser\.nuget\packages\microsoft.ui.xaml\2.5.0-prerelease.201027002\runtimes\win10-x64\native\Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png" to the output file as "Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png".
1>The mapping file can't be parsed.  The error occurs at line 185.
1>Package creation failed.
1>0x8007000b - An attempt was made to load a program with an incorrect format.

Expected behavior VS should successfully create an .msixupload package for certification and submission.

NuGet package version: [Microsoft.UI.Xaml.2.5.0-prerelease.201027002]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (13 by maintainers)

Most upvoted comments

Agreed, in the meantime @sis2004 can you try this workaround and let me know if this works for you:

<!-- This is a workaround for  https://github.com/microsoft/microsoft-ui-xaml/issues/3554 -->
  <Target Name="WorkaroundForIssue3554" BeforeTargets="_GenerateAppxUploadPackageFile" Returns="@(AppxUploadPackagePayload)">
    <ItemGroup>
      <!-- There is a duplicate of the noiseasset file. This happy little piece of code finds the duplicates-->
      <_FilteredAppxPackagePayload Include="@(AppxUploadPackagePayload)" Condition="'%(AppxUploadPackagePayload.TargetPath)'=='Microsoft.UI.Xaml\Assets\NoiseAsset_256X256_PNG.png'"/>
      
      <!-- This happy piece of code arbitrarily remove one of the duplicates based on some metadata that we can use to distinguish one of them. -->
      <_AppxPackagePayloadToRemove Include="@(_FilteredAppxPackagePayload)" Condition="'%(_FilteredAppxPackagePayload.ProjectName)'==''"/>

      <!-- Finally, remove one of the duplicates from the actual item group that's causing problems. This is the happiest of all the little code pieces. -->
      <AppxUploadPackagePayload Remove="@(_AppxPackagePayloadToRemove)"/>
    </ItemGroup>
  </Target>