3

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.

ispiro
  • 26,556
  • 38
  • 136
  • 291
  • The following may be helpful: [dumpbin](https://stackoverflow.com/a/3899746/10024425) and [CorFlags](https://stackoverflow.com/a/2418287/10024425). To open a `Developer Command Prompt for VS 2022` window (Start => Visual Studio 2022 => Developer Command Prompt for VS 2022). – Tu deschizi eu inchid Nov 16 '22 at 21:53
  • how \win-x86 folder get referenced? When I try to add wpf as app reference to packaging project, The folder is something like "...\WpfApp1\bin\Debug\net6.0-windows10.0.17763.0\WpfApp1.dll" – LarryX Nov 27 '22 at 15:31
  • @LarryX Great question. I have no idea. Maybe Visual Studio creates folders for every target (since it's targeting AnyCPU) and then mistakenly compares the wrong folders. But I really don't know. – ispiro Nov 27 '22 at 17:14

2 Answers2

1

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.

Orace
  • 7,822
  • 30
  • 45
  • Thanks, but did you try that and it worked for you? I did and it doesn't help. – ispiro Nov 24 '22 at 14:33
  • To be honest with you, I failed to reserve a name for the application, I am not used to the Microsoft Store. But while trying I saw that the default minimum version could be problematic, that's why I posted this answer which ultimately is useless. – Orace Nov 28 '22 at 09:47
  • Thank you for your kind gesture sir. Sorry that you didn't find a solution. – Orace Nov 28 '22 at 16:27
0

I had this problem also. When creating a new packaging project in Visual Studio 2022 (for a WinForms project) the problem disappeared. So by comparing my old and new packaging project I could see that the problem was that in the old project I had the following property set to true in my .wapproj file:

<ProjectReference Include="..\WinFormsProject\WinFormsProject.csproj">
      <SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
</ProjectReference>

So by removing SkipGetTargetFrameworkProperties it started working .

Johan O
  • 402
  • 5
  • 7