Search code examples
c#.netwpf.net-6.0desktop-bridge

Packaging project fails with mismatch between the processor architecture etc


Reproduce as follows:

On VS2022 (17.4.1) Windows 10 Pro (19045.2251)

  1. Create WPF project (.Net 6.0)
  2. Change target OS version (in project properties) to 10.0.19041.0 (doesn't matter)
  3. Add a packaging project.
  4. Add the WPF project as an "Application" to the packaging project.
  5. Select the packaging project in solution explorer.
  6. Project > Publish > Create app package.
  7. "Microsoft Store as..." (you'll need to associate it with some app).
  8. Create the package (it'll automatically target "Neutral - Release (AnyCPU").
  9. Get the following error:

There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "...\MyApp
MyApp\bin\x86\Release\net6.0-windows10.0.19041.0\win-x86\MyApp.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. WapProjTemplate1 C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets 2353

It used to work, and still does when clicking F5 even when setting the packaging project as startup project. But not when building the package for the Store.

How can I create a package for the Store now?

EDIT - More Info

Clicking on: Solution Explorer > (The solution) > Right click > Properties > configuration properties > configuration > and choosing "all configurations" in the top left ("Configuration" drop-down) shows me everything is targeting "AnyCPU", both debug and release. Also, all possible check boxes are checked.


Solution

  • While creating the packaging project, a pop-up is shown asking for target and minimum windows version:

    New Windows Project

    The default value for the minimum version is 10.0.17763.0 which is below the required 10.0.19041.0.
    You should choose 10.0.19041.0 for minimal version.
    This parameter can be edited in the TemplateProject.wapproj project file under the <TargetPlatformMinVersion> tag.